A couple kidnapped by a Taliban-affiliated group five years ago has been released along with their three children, all of whom were born in captivity.

American woman Caitlan Coleman, 31, and her Canadian husband Joshua Boyle, 34, were abducted while hiking in Afghanistan's Ghazni province in 2012.

Coleman was pregnant when she was captured. The couple had another two children while they were held by the Haqqani network, a guerrilla group that operates in Afghanistan.

The family's release was secured thanks to a joint effort by US and Pakistani officials, AP reported.

The Pakistani military said in a statement that US intelligence had been tracking the family, who crossed into Pakistan on 11 October.

"All hostages were recovered safe and sound and are being repatriated to the country of their origin," the military said.

A US national security official deemed Pakistan's cooperation as an important step to improve relations between the two countries.

The US has criticised Pakistan for failing to tackle the Haqqanis, who have been behind attacks against US and allied forces in Afghanistan.

The US Department of State said in a statement: "President Trump's new South Asia strategy recognises the important role Pakistan needs to play to bring stability and ultimately peace to the region.

"The United States is hopeful that Pakistan's actions will further a US-Pakistan relationship marked by growing commitments to counter-terrorism operations and stronger ties in all other respects."

A video of Coleman and her husband surfaced last year. Both hostages pleaded with their respective governments to secure their release. The footage also showed the couple's children.

"We can only ask and pray that somebody will recognise the atrocities these men carry out against us as so-called retaliation in their ingratitude and hypocrisy," said Coleman in the video.

"My children have seen their mother defiled," she continued.

The woman went on criticising both the Canadian and American governments as well as the extremist organisation. The video was published by extremist channels and shared by the US-based SITE intelligence group, which monitors terrorist activities.

The couple had already appeared in a video, in which they pleaded Washington to secure their release. Extremists warned the hostages would be killed if the the Afghan government continued executing Taliban prisoners.