Updated at 2:35 p.m. ET

An American woman, her Canadian husband and their three young children have been freed after five years in captivity by an extremist group in Afghanistan, the White House said Thursday.

Caitlan Coleman, now 32, was several months pregnant when she and her husband, Joshua Boyle, were abducted in 2012 while on a trip to Afghanistan.

That child, and two more, were born while the couple was held by the Haqqani network, an Afghan extremist group affiliated with the Taliban.

U.S. intelligence agencies were tracking the family and provided information to the Pakistanis as the hostages were moved across the border from Afghanistan to Pakistan, the Pakistan military said in a statement.

"The operation by Pakistani forces, based on actionable intelligence from U.S. authorities was successful," the Pakistan statement read. "All hostages were recovered safe and sound."

President Trump said in a statement: "Today they are free. This is a positive moment for our country's relationship with Pakistan."

A U.S. official told NPR that the Pakistani security forces used the U.S. intelligence to locate and stop the vehicle carrying the hostages. A gunfight broke out and the hostage-takers got away, but the family was rescued.

Then, in an unexpected twist, Boyle declined to get on a U.S. transport plane in Pakistan that would begin to take the family back to North America, a U.S. official said.

Boyle was previously married to another woman, Zaynab Khadr, whose family has been connected to extremists in Afghanistan. Two of her brothers were held by the United States in Guantanamo Bay. One of them, Omar Khadr, pleaded guilty to killing a U.S. soldier in Afghanistan. Omar Khadr spent a decade at Guantanamo, but is now free and living in Canada.

Boyle apparently had concerns about traveling with the U.S. military, fearing he might be detained. But U.S. authorities have given no such indication.

Meanwhile, Trump appeared to drop a hint about the hostage case in a speech Wednesday in Coleman's home state of Pennsylvania.

"Something happened today, where a country that totally disrespected us called with some very, very important news," he said.

"And one of my generals came in. They said, 'You know, I have to tell you, a year ago they would've never done that.' It was a great sign of respect. You'll probably be hearing about it over the next few days. But this is a country that did not respect us. This is a country that respects us now. The world is starting to respect us again, believe me," the president added.

Coleman and Boyle set off on an extended trip that took them through Russia and central Asia in the summer of 2012. Coleman's parents, Jim and Lyn Coleman, said the last contact they had with the couple was on Oct. 8, 2012, when their son-in-law reached them from an Internet cafe in Afghanistan.

Last December, the couple appeared in a YouTube video, pleading for the U.S. and Canadian governments to help win their release.

"Indeed they threaten to retaliate against our family," Coleman says in the video. "Their group will do us harm and punish us. So we ask that you are merciful to their people and, God willing, they will release us."

Two young children appear in the video with them. The Toronto Star reports Boyle told his father that the couple has since had a third child.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.