U.S. Army Sgt. Bowe Bergdahl was handed over May 31 by members of the Taliban.

U.S. Army Sgt. Bowe Bergdahl, the only U.S. service member known to be held hostage in Afghanistan, was handed over Saturday morning by members of the Taliban in exchange for five Afghan detainees held at the military prison in Guantanamo Bay, Cuba, U.S. officials said.

U.S. Army Sgt. Bowe Bergdahl, the only U.S. service member known to be held hostage in Afghanistan, was handed over Saturday morning by members of the Taliban in exchange for five Afghan detainees held at the military prison in Guantanamo Bay, Cuba, U.S. officials said.

— They were among the Taliban’s most influential commanders — five men whom the United States succeeded in removing from the battlefield.

But on Saturday, they were released from the military prison in Guantanamo Bay, Cuba, in exchange for Army Sgt. Bowe Bergdahl — a deeply controversial decision that raised concerns in Kabul and Washington even as Bergdahl’s homecoming was celebrated.

One of the freed men was the head of the Taliban’s army. Another arranged for al-Qaeda trainers to visit Afghanistan. Another has been implicated by the United Nations for killing thousands of Shiite Muslims.

Although the five men have each been in prison for at least a decade, many believe they still have significant influence within the Taliban because of their contributions during the group’s formative years. The last time a high-level Taliban official was released from Guantanamo, in 2007, the detainee, Mullah Abdul Qayyum Zakir, returned to Afghanistan and took the reins as the organization’s director of military operations.

Like Zakir, the five detainees released Saturday and handed to the Qatari government had formal government jobs when the Taliban ruled Afghanistan from 1996 until 2001. They will remain in Qatar for a year. Beyond that, it remains unclear whether they will be able to move to Pakistan or Afghanistan.

A Taliban statement on Saturday announced the release “with great happiness” and said the men would live with their families in Qatar.

The releases come at a pivotal moment in the Afghan war. The United States is concluding its combat mission, and the Afghan army is preparing to take on a powerful insurgency with far less assistance from the American military. The Taliban vowed as recently as last week that “jihad is incumbent and our nation will continue its righteous jihad.”

If they are permitted to return to Pakistan or Afghanistan, the five former detainees will likely play a crucial role in the Taliban’s next act.

Khirullah Said Wali Khairkhwa, 47, was once the Taliban’s interior minister. He helped create the Taliban movement in 1994. He was a “hard-liner in his support of the Taliban philosophy” and “was known to have close ties to Osama bin Laden,” according to his Guantanamo case file, released by WikiLeaks.

Mullah Mohammad Fazl was a senior commander in the Taliban army in the 1990s, rising to become its chief of staff. He is thought by many to have supervised the killing of thousands of Shiite Muslims near Kabul between 1998 and 2001. According to WikiLeaks documents, he was also present at the 2001 prison riot that killed CIA operative Johnny Micheal Spann, the first U.S. citizen killed in the Afghan war.

Mullah Norullah Noori, another of the detainees, was also present during Spann’s killing. He was a provincial governor in several key areas during the Taliban regime. He is also suspected of involvement in the Shiite massacre.

Abdul Haq Wasiq, 43, was deputy chief of intelligence for the Taliban. According to his Guantanamo case file, he “utilized his office to support al Qaeda” and was “central to the Taliban’s effort to form alliances with other Islamic fundamentalist groups.” His case file, like Khairkhwa’s, calls him a “high risk,” saying that he is likely to “pose a threat to the US, its interests and allies.”

Mohammad Nabi Omari, 46, was a member of a joint al-Qaeda-Taliban cell in eastern Khost province, according to his case file, and “one of the most significant former Taliban leaders detained” at Guantanamo. He has ties to the Haqqani network, the group that was believed to be holding Bergdahl.

Over and over, each detainee received a “recommendation for continued detention” by a military board at Guantanamo. But Bergdahl’s kidnapping — and the prospect of a prisoner swap — meant those recommendations would have to be reassessed.

The Afghan government had long supported the idea of a prisoner release from Guantanamo, but with an eye toward reconciliation, not Bergdahl’s return. In 2011, President Hamid Karzai said of Khairkhwa, “We would talk to him, we would arrange his release.”

In 2012, Karzai said he sent a delegation of Afghan officials to Guantanamo, where they interviewed Afghan prisoners. He then became more strident in his demands, asking for the release of all Afghans held at the detention facility.

“We want the release of those Taliban figures, and we want them to have the freedom to settle where they want,” he said.

Karzai’s office could not be reached for comment Saturday, but it seems likely that his administration will be disappointed that the prisoner swap wasn’t attached to broad reconciliation efforts. Lower-ranking Taliban commanders, released from the Bagram prison by the Afghan government over the past year, have already returned to the battlefield, according to U.S. officials.

After Saturday’s release, 12 Afghans remain at Guantanamo.

Within hours of the White House’s statement about Bergdahl’s release, members of Congress began raising concerns about the detainees.

“These particular individuals are hardened terrorists who have the blood of Americans and countless Afghans on their hands,” Sen. John McCain (R-Ariz.) said in a statement. “I am eager to learn what precise steps are being taken to ensure that these vicious and violent Taliban extremists never return to the fight against the United States and our partners or engage in any activities that can threaten the prospects for peace and security in Afghanistan.”

Julie Tate in Washington and Sayed Salahuddin in Kabul contributed to this report.