FILE - This image taken from video released by Pakistan's military, shows what they claim to be an Indian pilot who was captured after his plane was shot down by Pakistan's Air Force in the country's part of Kashmir. This week’s standoff between India and Pakistan is their latest in a long dispute over the divided Himalayan region of Kashmir, dating back to their independence in 1947. (Pakistan military via AP, File)
FILE - This image taken from video released by Pakistan's military, shows what they claim to be an Indian pilot who was captured after his plane was shot down by Pakistan's Air Force in the country's part of Kashmir. This week’s standoff between India and Pakistan is their latest in a long dispute over the divided Himalayan region of Kashmir, dating back to their independence in 1947. (Pakistan military via AP, File) Credit: ap — Prabhjot Gill

WAGAH, Pakistan — 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 neighbors 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 gray 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 on 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 neighbors 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 on 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.

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.

Meanwhile, cross-border shelling continued on Friday, with residents of the Pakistani border town of Chikhoti reporting heavy mortar fire.