President Trump hailed the news of American woman and her family rescued from terrorists in Pakistan after five years in captivity as a victory for the United States and "a positive moment" for the relationship with Pakistan.

The relationship with Pakistan has been strained by disagreements about how to target terrorist groups operating in the country, but the two sides cooperated to rescue Caitlan Coleman, her husband Joshua Boyle, and their three children.

"Today they are free," Trump said. "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."

Coleman and Boyle were captured while hiking in Afghanistan in 2012. Coleman was pregnant with their first child at the time. They had been held by the Haqqani network, an insurgent group on the border of Afghanistan and Pakistan that is tied to the Taliban and receives "the backing of elements within the Pakistani security establishment," according to the Institute for the Study of War.

Pakistan's military announced Thursday they had carried out the rescue operation "based on actionable intelligence from US authorities" who reported the family had been brought to a certain Pakistani village on Wednesday.

"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," Pakistan's army said in a statement.

Trump's team has sought to increase pressure on Pakistan to cooperate in counterterrorism issues, warning the country was "on notice" and might even lose its status as a major non-NATO ally.

"We are going to be engaging with them in a very serious and thorough way as to our expectations and the conditions that go with that," Secretary of State Rex Tillerson said in August. "All those things ... are on the table for discussion, if, in fact, they are unwilling to change their posture or change their approach to how they're dealing with the numerous terrorist organizations that find safe haven in Pakistan."

Tillerson echoed Trump's applause for the rescue with an eye on the administration's broader effort to improve Pakistan's counterterrorism efforts.

"President Trump's new South Asia strategy recognizes the important role Pakistan needs to play to bring stability and ultimately peace to the region," Tillerson said Thursday. "The United States is hopeful that Pakistan's actions will further a U.S.-Pakistan relationship marked by growing commitments to counterterrorism operations and stronger ties in all other respects."