Tariq Azizuddin, his driver, and bodyguard were traveling to the Afghan capital, Kabul, when they disappeared in the border area between the two countries on February 11.
Relatives, friends, and the media gathered at the ambassador's residence in the city of Rawalpindi, near Islamabad, after Azizuddin was flown there from the northwestern city of Peshawar. On his return, Azizuddin said he was thankful to God and praised the efforts of the government to secure his freedom.
Azizuddin, who had grown a long beard and appeared exhausted, said he was treated well while in captivity.
Pakistan's Foreign Ministry says the ambassador's driver and bodyguard were also released and are safe.
Ongoing Peace Talks
The releases came amid peace talks between Pakistan's new government and militant groups. But Rehman Malik, a security adviser to the prime minister, denied any deal had been struck to get the envoy and the two others freed, saying Azizuddin's release was "purely a result of law enforcement efforts." He did not give more details.
The French news agency AFP quoted an unidentified security official as saying the ambassador was recovered late on May 16 from the custody of a local Taliban group just outside the Khyber tribal district in Pakistan. Other media reports in Pakistan said the envoy had been freed in Afghanistan.
Azizuddin was travelling from the northwestern Pakistani city of Peshawar when he was abducted.
Azizuddin's release came nearly one month after he appeared in a video on Dubai-based Al-Arabiyah television in which he said he and his colleagues were being "looked after." But Azizuddin also said he suffered from health problems, including high blood pressure and heart pains.
In the April video, in which a militant could be seen holding a gun to the envoy's head, Azizuddin said he had been seized in the Khyber area, near the Afghan border. He said he had been taken by "mujahedin from the Taliban," and urged the Pakistani government to meet the demands of the kidnappers. He didn't say what demands the Taliban were making, but Pakistani media reported the militant group had called for the release of prisoners.
A purported spokesman for the Taliban in Pakistan has denied that the group was responsible for abducting the envoy, however.
The ambassador's disappearance highlighted mounting lawlessness in Pakistan's tribal belt on the Afghan border, where many areas are strongholds of pro-Taliban militants. Hundreds of people have been abducted and killed in the region in recent months.
Azizuddin's kidnapping coincided with Pakistani security forces seizing a senior Taliban commander, Mullah Mansur Dadullah, in southwestern Baluchistan Province, also bordering Afghanistan.
Ongoing peace talks between Islamabad and militant groups this week produced an exchange of prisoners, including 18 security personnel and 55 pro-Taliban militants. The move came ahead of a formal peace deal the Pakistani government is set to sign with pro-Taliban militants.
Compiled from agency reports, with Sarwan Asmatullah of RFE/RL's Radio Free Afghanistan