The last time anyone heard from Caitlan Coleman, the York County, Pa., native spoke of the "Kafkaesque nightmare" she and her husband, Joshua Boyle, had been trapped in for nearly five years.

The couple were kidnapped in Afghanistan in 2012 and held in Pakistan by a criminal network linked to the Taliban. Through the years, videos and letters trickled out from their captors: Coleman and Boyle begging for freedom and for "money, power and friends" for the Haqqani network holding them prisoner.

In the last, chilling video, released in December, two of the couple's children, both born in captivity, appeared on screen. "My children have seen their mother defiled," Coleman read from a script.

On Thursday, the family — including a third child, born since the video's release — was free, according to the U.S. and Pakistani governments.

Their rescue was likely to finally lead to some resolution of the mystery surrounding their capture and extended imprisonment. Nearly two dozen westerners are believed to be detained by Taliban affiliates, although the couple's plight had been among the most chronicled.

Details on their rescue were scant Thursday. Coleman, of Stewartstown, and Boyle, son of a Canadian judge, and their children — two boys and a girl — were reportedly at the U.S. Embassy in Islamabad. It wasn't clear when or if they would return to the United States.

"They've been essentially living in a hole for five years," White House Chief of Staff John Kelly said in a briefing. "Thank God that the Pakistani officials took them into custody, so to speak, from the forces of evil in that part of the world, and they're being taken care of as we speak."

Coleman's parents placed a note on their front door Thursday afternoon asking for privacy as they "make plans for the future." They called the release of Coleman, Boyle, and their grandchildren "joyous news."

Boyle told his parents Thursday morning that he was in the trunk of the kidnappers' car with his wife and children when Pakistani forces opened fire, killing five militants and rescuing the family, the Toronto Star reported. Boyle said the last words he heard from the kidnappers were, "Kill the hostages," the newspaper said.

In a video statement provided to the Star, Boyle's parents said that they had spoken with their son before dawn Thursday and that he had told them how much his children were looking forward to meeting their grandparents. They gave their "profound thanks" to American, Canadian and Pakistani officials who worked to free their son and daughter-in-law, and to the Pakistani soldiers who "risked their lives" to save them, they said.

A government official familiar with the situation said numerous agencies, including the FBI, Department of Defense and State Department had been involved in a years-long effort to secure the family's release, though this person was unclear on what happened to change the situation this week.

"They have a really tough road ahead of them," said the official, who was not authorized to speak publicly about the operation. "They have been living a nightmare for five years. I think they are going to need some time to adjust back into their old lives."

Over the course of Coleman's captivity, there were questions about where she and her family were being held and who were the key decision-makers among their captors, the official said. The Haqqani network is a sophisticated organization labeled a terrorist group by the U.S. and also a criminal enterprise.

Some of the videos the group released of Coleman and Boyle included demands that the U.S. release fighters Americans had detained.

The couple met online, bonded over a love for Star Wars, and married in Central America in 2011.

A friend of Boyle's who, citing the sensitivity of the case and concerns about his job, asked to be identified only by his first name, Greg, said he met the intensely private Boyle about 15 years ago playing an online Star Wars game. They became close, he said, and Boyle eventually attended his wedding.

"He was so funny and so charismatic," he said. Boyle and Coleman had been friends for some time online before they married, he said.

"He raved about her — how good a person she is, and how smart she is," Greg said.

Adventurous travelers, Coleman and Boyle had planned a backpacking trip through Kyrgyzstan, Kazakhstan, and Tajikistan in 2012. Afghanistan had never been on the itinerary. Boyle had spoken sometimes, Greg said, of visiting Afghanistan once the conflict there was resolved, to write about the aftermath of the war there. But his friend said Boyle hadn't told him about any current plans to travel there.

"I kind of wish he would have told me, because I would have said, 'Hey, dummy, what are you doing?" Greg said.

The last their parents heard from them before their capture was an email Boyle sent from an Internet cafe there, saying he was in an "unsafe" part of Afghanistan.

They would appear sporadically in videos from the Haqqani network over the years, saying their captors had threatened to kill them if the Afghan government would not stop executing Taliban prisoners.

Previously, Boyle was married for a year to Zaynab Khadr, whose father had suspected ties to al-Qaeda and whose brother was arrested in Afghanistan at age 15 and held at Guantanamo Bay for years. Canadian officials have said his kidnapping was likely unrelated to his ex-wife's family ties, and friends have said Boyle was a pacifist, raised as a Mennonite, who became involved with the Khadr family because of his interest in human rights.

CNN reported Thursday that a "senior U.S. official" said Boyle had refused to board a plane to the U.S. because he was concerned he would face arrest, though there was "no indication at the time" that he would.

In a speech outside Harrisburg on Wednesday, President Trump had hinted that the family's release was imminent: "Something happened today where a country that totally disrespected us called with some very, very important news;" Press Secretary Sarah Huckabee Sanders confirmed Thursday that he had been referencing Coleman and Boyle.

In December, Sen. Bob Casey (D., Pa.) said Coleman's family was "a model of persistence and determination" through "the most horrific of situations."

On Thursday, Casey commended both the Trump and Obama administrations for their efforts.

"Today, our commonwealth and our country give thanks that Caitlan Coleman, Josh Boyle, and their children have been released from captivity," he said in a statement. "This day is also special for Jim and Lyn Coleman, who have spent the last five years devoted to the mission of bringing their loved ones home. They have been living any parent's nightmare, and today they can begin to heal and recover."

Sen. Pat Toomey (R., Pa.) said in a statement that Coleman's parents "never gave up hope that this day would come."

"I applaud the work of President Trump, Secretary Tillerson, and the entire national security team for their diligent efforts to secure their release," he said.

Rep. Scott Perry (R., Pa.), who represents Coleman's district, said he had "an inkling" last night when the president visited Harrisburg and he spoke briefly with him. The official word came early Thursday. "We weren't sure of anything until this morning."

He praised the Trump administration for adding new emphasis to the push for Coleman's release.

"I sensed a different sense of urgency from the current administration. We've been working with the last one and we were just frustrated at every turn," Perry said. "A lot of conversation, but didn't seem to be a lot of action."

Staff writers Angela Couloumbis and Jonathan Tamari contributed to this article.