In an unusual moment on Wednesday night, Mr. Trump appeared to telegraph the familyâs impending release.
âAmerica is being respected again,â the president said during a speech on his tax plan in Harrisburg, Pa. âSomething happened today where a country that totally disrespected us called with some very, very important news. And one of my generals came in, they said, you know, I have to tell you, a year ago they would have never done that. It was a great sign of respect. Youâll probably be hearing about it over the next few days.â
Mr. Trump did not mention Ms. Coleman, Mr. Boyle or Pakistan, but the revelation was notable for a president who had often complained that President Barack Obama shared what Mr. Trump viewed as important secrets, such as battle plans against the Islamic State.
Pakistanâs relationship with the United States has been rocky. The United States has long accused Pakistanâs military and its intelligence agency of harboring or ignoring militants, and relations have grown increasingly strained over Pakistanâs role in Afghanistan.
In a statement about the hostage release, the Pakistani army said: â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.â
The end of the familyâs captivity was a victory for the State Department officials and the F.B.I.-led Hostage Recovery Fusion Cell that had worked on the case for years. The group was created under the Obama administration to improve the governmentâs efforts to free hostages and to ensure their families received timely information about them.
Previously, the Haqqani network had demanded the release of Anas Haqqani, one of its commanders, in exchange for the familyâs freedom. The Afghan government captured Mr. Haqqani in 2014, and he was sentenced to death. The militant group had threatened to kill the family if he was executed.
In December 2016, the militants released a video of the family, including footage depicting their children. Ms. Coleman described her time as a hostage as âKafkaesqueâ and said she had been âdefiled.â
âIndeed, they threaten to retaliate against our family,â she said. â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.â
An earlier video made public in August 2016 showed the couple. During it, Ms. Coleman urged the American government to âhelp stop this depravity.â She also said her captors âwill execute us.â
Earlier attempts to bring the family home fell short. In January 2016, Colin Rutherford, a Canadian, was freed after Qatar arranged a prisoner swap with the Afghan government. Officials had hoped Mr. Rutherford would be the first in a series of releases, including Ms. Coleman and her family.
But that never materialized, for reasons that remain unclear. The Obama administration sought to jump-start talks with the Taliban but those efforts faltered after the American military killed Mullah Akhtar Muhammad Mansour, the Talibanâs leader, in a drone strike in May of 2016.
The Haqqanis are believed to be holding an American university professor who was kidnapped in August of 2016. On a video released earlier this year, the man, Kevin King, pleaded for Mr. Trump to free him: âHave mercy on me and get me out.â
Another American, Paul Overby, disappeared in May 2014 and has not been seen since his abduction. He was trying to interview the head of the Haqqani network when he was abducted.
The Trump administration has had modest success in freeing Americans held overseas. In April, an Egyptian-American woman was released in Egypt after being held for nearly three years on human trafficking charges. Another American, Otto Warmbier, a student, was released from North Korea but died days later. His family said Mr. Warmbier, who had been in a coma, was tortured.
Three other Americans remain imprisoned in North Korea.
The C.I.A. director, Mike Pompeo, tried to open a backchannel to the Syrian government to help free Austin Tice, an American journalist and former Marine officer, who is being held in Syria. His exact whereabouts is unknown, but American officials believe the Syrian government knows where he is being held.