An American woman, her Canadian husband and their three young children have been released after years held captive by a network with ties to the Taliban, US and Pakistani officials said.
Pakistan secured the release of Caitlan Coleman and her husband, Canadian Joshua Boyle, who were abducted five years ago while travelling in Afghanistan and had been held by the Haqqani network in Pakistan.
Ms Coleman, from Pennsylvania, was pregnant when she was captured.
The couple had three children while in captivity, and all have been freed, US officials said.
A US national security official commended Pakistan for their critical assistance in securing the family's release, and described the cooperation as an important step in the right direction for US-Pakistani relations.
The US has long criticised Pakistan for failing to aggressively go after the Haqqanis, who have been behind many attacks against US and allied forces in Afghanistan.
In Pakistan, its military said in a statement that U.S. intelligence agencies had been tracking the hostages and discovered they had come into Pakistan on October 11 through its tribal areas bordering Afghanistan.
"All hostages were recovered safe and sound and are being repatriated to the country of their origin," the military said.
Three Pakistani military officials, all speaking on condition of anonymity as they were not allowed to speak to journalists, also confirmed the hostages' identities.
The release, which came together rapidly Wednesday, comes nearly five years to the day since Ms Coleman and Mr Boyle lost touch with their families while travelling in a mountainous region near the Afghan capital, Kabul.
The couple set off in the summer 2012 for a journey that took them to Russia, the central Asian countries of Kazakhstan, Tajikistan and Kyrgyzstan, and then to Afghanistan.
Ms Coleman's parents last heard from their son-in-law on October 8 2012, from an internet cafe in what Mr Boyle described as an "unsafe" part of Afghanistan.
In 2013, the couple appeared in two videos asking the US government to free them from the Taliban.
Ms Coleman's parents, Jim and Lyn Coleman, told the online Circa News service in July 2016 that they received a letter from their daughter in November 2015, in which she wrote that she had given birth to a second child in captivity.
It was unclear whether they knew she had had a third.
"I pray to hear from you again, to hear how everybody is doing," the letter said.
In that interview, Jim Coleman issued a plea to top Taliban commanders to be "kind and merciful" and let the couple go.
"As a man, father and now grandfather, I am asking you to show mercy and release my daughter, her husband, and our beautiful grandchildren," Jim Coleman said.
"Please grant them an opportunity to continue their lives with us, and bring peace to their families."
The family was being held by the Haqqani network.
US officials call the group a terrorist organisation and have targeted its leaders with drone strikes.
But the group also operates like a criminal network.
Unlike the Islamic State group, it does not typically kill Western hostages, preferring to ransom them for cash.