UNDATED - In this undated image provided by the U.S. Army, Sgt. Bowe Bergdahl poses in front of an American flag. U.S. officials say Bergdahl, the only American soldier held prisoner in Afghanistan, was exchanged for five Taliban commanders being held at Guantanamo Bay, Cuba, according to published reports. Bergdahl is in stable condition at a Berlin hospital, according to the reports. (Photo by U.S. Army via Getty Images) (U.S. Army/Getty Images)

PRESIDENT OBAMA and his top aides are taking satisfaction in the release of Sgt. Bowe Bergdahl from nearly five years of captivity by the Taliban. While it may be, as some former comrades allege, that Sgt. Bergdahl’s capture followed his desertion of his post, by obtaining his release the administration upheld the principle that, as Mr. Obama put it, “the United States of America does not ever leave our men and women in uniform behind.” That will be a comfort to many families beyond the Bergdahls, whose dedication to their son is inspiring.

For all that, the administration’s handling of the matter raised some troubling questions. In releasing five senior Taliban commanders from Guantanamo Bay prison to the de facto custody of Qatar, Mr. Obama appears to have sidestepped a law requiring that Congress be notified before such releases from Guantanamo take place. The Afghan government, which was not informed of the prisoner swap before it took place, angrily alleged that it also violated international law by transferring detainees to a third country. Congressional Republicans charged that the administration had breached its policy of refusing to negotiate with terrorists — a precept it confirmed just weeks ago in advising Nigeria’s government not to negotiate with the Boko Haram movement about abducted schoolgirls.

The administration’s answers to these critiques are only partially satisfying. It says it did not negotiate with terrorists, since the exchange was brokered through Qatar and not directly with the Taliban. Sgt. Bergdahl and the Taliban commanders, officials add, were prisoners of war, not hostages. Probably the president’s lawyers are correct in saying that the Constitution gives Mr. Obama the authority to carry out such exchanges; a signing statement he attached to the Guantanamo legislation asserts as much. Moreover, administration officials say they were obliged to move quickly because of concern about Sgt. Bergdahl’s health.

Still, the impression reinforced by the deal is of a president anxious to disengage from Afghanistan as rapidly and as thoroughly as possible, with minimal regard for the consequences for Afghans. U.S. officials, who have been talking about a possible exchange of Sgt. Bergdahl for the Taliban commanders for several years, once presented it as a possible first step toward an Afghan peace accord. However, administration officials now play down that notion, and the Taliban dismissed it out of hand.

In a rare statement, the movement’s leader, Mohammad Omar, instead said the release of the commanders brought the insurgency “closer to the harbor of victory.” The released militants’ movements will be confined inside Qatar for a year, but there’s no sign the men are ready to give up the fight against the Afghan government. Now that Mr. Obama has committed to withdrawing all U.S. forces from Afghanistan by the end of 2016, the Taliban have scant incentive to negotiate either with Kabul or Washington.

For Mr. Obama, the release of Sgt. Bergdahl wraps up one loose end of the Afghan war, and the release of the commanders resolves another. The president has confirmed the United States’ unswerving commitment to its servicemen, and he has once again made clear to Afghans that U.S. backing for their fragile state is anything but firm.