ISLAMABAD/WASHINGTON (Reuters) - A kidnapped U.S.-Canadian couple and their three children born in captivity have been freed in Pakistan, nearly five years after the couple was abducted in neighboring Afghanistan, Pakistani and U.S. officials said on Thursday.

American Caitlan Coleman and her Canadian husband, Joshua Boyle, were kidnapped while backpacking in Afghanistan in 2012 by the Taliban-allied Haqqani network, which the United States has long accused Pakistan of failing to fight.

U.S. President Donald Trump, who has been highly critical of Islamabad, praised Pakistan’s cooperation with the U.S. government over the freeing of the hostages, saying it represented “a positive moment” for U.S.-Pakistan relations.

“The Pakistani government’s cooperation is a sign that it is honoring America’s wishes for it to do more to provide security in the region,” Trump said in a statement.

Trump’s chief of staff, John Kelly, drove home the dire conditions that the family had been subjected to during its long captivity.

“They’ve been essentially living in a hole for five years,” Kelly said. “That’s the kind of people we’re dealing with over there.”

It was unclear how precisely the Pakistani military secured the family’s release, which came after the United States shared intelligence about the hostages’ location. It was also unclear when the family would return home.

Two U.S. officials, speaking on condition of anonymity, told Reuters that the U.S. military had been ready to fly the family out of the country but said Boyle, who is Canadian, had refused to board the aircraft.

Boyle had once been married to the sister of an inmate at the U.S. military detention center at Guantanamo Bay. The marriage ended and the inmate was later released to Canada.

As of Thursday evening, there was no indication the family had left Pakistan. Boyle’s parents said he told them by phone he would see them in a couple of days.

“So we’re waiting for that,” his mother, Linda Boyle, said in a video posted on the Toronto Star newspaper’s website.

U.S. officials expressed hope that the hostages’ freedom could represent a turning point in relations between Pakistan and the United States, uneasy allies in fighting Taliban and other Islamist extremists in the region.

In recent days, senior U.S. officials have been more pointed about Islamabad’s alleged ties to militant groups, who are battling against U.S. and U.S.-backed forces in a stalemated 16-year-old war in neighboring Afghanistan. Some U.S. officials say Pakistani safe havens have helped prolong the conflict.

Pakistan fiercely denies such ties, and it touted the operation as proof of the strength of the alliance.

“The success underscores the importance of timely intelligence sharing and Pakistan’s continued commitment towards fighting this menace through cooperation between two forces against a common enemy,” a Pakistani army statement said.

SHRAPNEL WOUNDS

Boyle’s father, in the video message, offered his thanks to Pakistani forces “who risked their lives and got all five of ours out safely and rescued.”

A still image from a video posted by the Taliban on social media on December 19, 2016 shows American Caitlan Coleman (L) speaking next to her Canadian husband Joshua Boyle and their two sons. Courtesy Taliban/Social media via REUTERS

The Toronto Star reported that Boyle told his parents that he was in the trunk of the kidnappers’ car with his wife and children when they were rescued by Pakistani forces. Boyle said he sustained minor shrapnel wounds during the shootout, which left his kidnappers dead.

“The last words Boyle said he heard from the kidnappers were, ‘kill the hostages,’” the Star reported.

The Pakistani army said its forces were able to recover the hostages after acting on U.S. intelligence about their passage into Pakistan from Afghanistan.

The White House, Pentagon and State Department did not offer details about the Pakistani effort, even as it praised cooperation from Islamabad.

But one U.S. official, speaking on condition of anonymity, said there was no indication that the hostages had been in Afghanistan in the days before they were freed, contrary to the Pakistani account.

The United States believed the hostages were probably held by the Haqqani group in or near its headquarters in northwestern Pakistan the entire time, two other U.S. officials said.

Declining to discuss U.S. intelligence in detail that was shared with Pakistan, they said the United States had been tracking cars capable of holding six or more people moving from place to place, which analysts had concluded were suggestive of moving hostages.

“It was a matter of interdicting vehicles,” another U.S. official told Reuters, saying the United States never dictated to Pakistan how precisely to secure the hostages’ release.

Canadian Foreign Minister Chrystia Freeland asked for respect for the family’s privacy.

“Joshua, Caitlan, their children and the Boyle and Coleman families have endured a horrible ordeal over the past five years. We stand ready to support them as they begin their healing journey,” Freeland said.

Coleman was pregnant at the time she was kidnapped, and a video released by the Taliban in December showed two sons born while she and her husband were hostages. Thursday’s statements from Islamabad and Washington were the first mention of a third child.

Some officials said Pakistanis’ motive for freeing the hostages may have been political rather than humanitarian, intended to reduce the tensions ahead of upcoming visits by Secretary of State Rex Tillerson and Defense Secretary Jim Mattis.

Tillerson in a statement said Trump’s strategy in the region recognized “the important role Pakistan needs to play to bring stability and ultimately peace to the region.”

Mattis, who last week said the United States would try “one more time” to work with Pakistan in Afghanistan, was upbeat on Thursday.

“This is a very positive moment and the Pakistan army performed well,” Mattis told reporters during a trip to Florida.