The American hostage, Caitlan Coleman, her Canadian husband and their three children were freed from captivity “through an intelligence-based operation by Pakistan troops,” according to a statement from the Pakistani government. But the family was not yet in American hands. The Pakistanis said the hostages, captured in Afghanistan in 2012, were tracked as they were moved across Pakistan. “The operation by Pakistani forces, based on actionable intelligence from U.S. authorities, was successful,” the statement said.

Mr. Trump raised the matter in his speech in Harrisburg to boast that he had made the United States an object of respect again around the world. A global poll this year actually showed a drastic drop in faith in American leadership since Mr. Trump took over in most of the countries surveyed. But the president presumably meant that foreign governments and factions like the Taliban group that was holding the American woman were now taking the United States more seriously since he assumed power.

“America is being respected again,” Mr. Trump told the crowd in Harrisburg. “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. 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.”

Respect is important in the Trump zeitgeist and his regular eruptions of anger are often the result of his feeling disrespected. In this case, the release of the hostages was accomplished with the assistance of Pakistan, which Mr. Trump has sought to pressure to do more to curb militant groups operating on its territory.