Pakistan handed over a captured Indian air force pilot to Indian officials at a border crossing on Friday, a “gesture of peace” by Pakistani Prime Minister Imran Khan aimed at defusing a dramatic escalation between the nuclear-armed neighbours over the disputed region of Kashmir.

The pilot, identified as Wing Commander Abhinandan Varthaman, walked across the border near the Pakistani town of Wagah after being taken in a convoy earlier in the day from the eastern city of Lahore, escorted by military vehicles and soldiers, their weapons drawn. Dressed in a blue blazer and grey dress pants, he was greeted by Indian policemen and military personnel on the Indian side.

The freed pilot was scheduled to undergo a detailed medical exam before boarding a flight from Amritsar, near the India-Pakistan border, to New Delhi for a debriefing with top air force officials about his captivity.

“The nation is proud of your exemplary courage,” Indian Prime Minister Narendra Modi said in a tweet.

The Pakistani military has said it shot down Varthaman's MiG-21 fighter jet on the Pakistani-held side of Kashmir on Wednesday and that the pilot safely ejected.

In a message aired on Pakistani television, Varthaman was seen in his green flight suit saying he was rescued by two Pakistani military personnel when he ejected and found himself in Pakistani-controlled territory surrounded by a group of angry residents. It was not clear when he recorded the statement, but it clearly happened while he was in the custody of the Pakistani military.

Varthaman was accompanied to the border Friday by the International Committee of the Red Cross. His handover took several hours as procedures including a checkup to verify his health and medical condition were completed before he was turned over to Indian officials.

Earlier in the day, the road on the Indian side of the border had been lined with well-wishers, but by the time Varthaman crossed around 9 p.m. most of them had left.

The handover came against the backdrop of blistering cross-border attacks across the disputed Himalayan region of Kashmir that continued for a fourth straight day, even as the two nuclear-armed neighbours sought to defuse their most serious confrontation in two decades.

Tensions have been running high since Indian aircraft crossed into Pakistan on Tuesday carrying out what India called a pre-emptive strike against militants blamed for a Feb. 14 suicide bombing in Indian-controlled Kashmir that killed 40 Indian troops. Pakistan retaliated, shooting down the MiG-21 fighter jet Wednesday and capturing Varthaman.

Since the escalation, world leaders have scrambled to head off an all-out war between the archrivals. President Donald Trump, in Hanoi on Thursday, said he had been involved in seeking to de-escalate the conflict.

Khan announced in parliament on Thursday that the pilot would be returned, calling the release “a goodwill gesture.”

But India made clear there could be no conditions attached to the pilot's return, and that the latest escalation had changed its strategy. Going forward, Indian officials said they would strike targets, including those inside Pakistani territory, if officials receive intelligence of planned attacks.

Despite the pilot's return, the path forward was uncertain for two countries that have faced off for years along the Kashmir boundary known as the Line of Control, in one of the world's most volatile regions.

“Let us hope this momentum created by the release of Wing Commander Abhinandan Varthaman translates into something long-term in terms of securing peace,” said Amitabh Mattoo, a professor of disarmament studies at New Delhi's Jawaharlal Nehru University. “We will have to wait and see.”

Also Friday, Pakistan's civil aviation authority partially re-opened the country's airspace, allowing commercial passenger travel to four major cities, another sign that tensions with India were de-escalating.

The agency said in a statement that all domestic and international flights would resume to and from the cities of Karachi, Islamabad, Peshawar and Quetta. It said other airports, including one in the eastern city of Lahore that borders India, would remain closed until Monday.

Islamabad closed its airspace Wednesday after announcing that Pakistan's military shot down two Indian warplanes and captured the Indian pilot. India said only one of its planes was lost, the MiG-21 flown by Varthaman, and Pakistan has not clarified the discrepancy.

Meanwhile, cross-border shelling continued Friday, with residents of the Pakistani border town of Chikhoti reporting heavy mortar fire that sent more than 200 people fleeing to a military-organized evacuation camp about 20 kilometres (16 miles) from the border.

Police in Indian-controlled Kashmir said one man was wounded and at least two civilian homes were damaged in the cross-border shelling.

Kashmir has been divided but claimed in its entirety by both India and Pakistan since almost immediately after the two countries' creation in 1947. The countries have fought three wars, two directly related to the disputed region.

Associated Press writers Kathy Gannon and Munir Ahmed in Islamabad, Roshan Mughal in Muzafarabad, Pakistan, Aijaz Hussain in Srinigar, India, and Ashok Sharma in New Delhi, India, contributed to this report.