An Afghan soldier stands guard outside Bagram prison, north of Kabul, in February 2014. (Shah Marai/AFP/Getty Images)

Even as President Obama pushes to close the Guantanamo Bay detention center in Cuba before he leaves office, another legacy of post-9/11 U.S. detention policies persists here in Afghanistan, where three men languish in one of the world’s toughest prisons despite court orders for their release.

Thousands of suspected militants were picked up by U.S. and Afghan forces after the fall of the Taliban government in late 2001. Many were sent to a U.S.-run prison at Bagram air base on the outskirts of Kabul, including dozens of non-Afghans kept for years without formal charges or public disclosure of their whereabouts.

A little more than a year ago, amid growing pressure from human rights activists, the U.S. military completed the handover of the prison to Afghan control. At least three non-Afghan prisoners remain incarcerated there, even though the country’s highest courts have agreed they should be freed.

“They have just been left there,” said Tina M. Foster, a lawyer with the International Justice Network, which works on detainee issues. “They are basically condemned to die there.”

The cases, involving two brothers from Tajikistan and a man from Uzbekistan, are a subset of the broader issues facing the Obama administration as it tries to bring more order to detention policies implemented after the Sept. 11, 2001, terrorist attacks.

Since Obama took office in 2009, the population at Guantanamo, where prisoners considered most likely to commit a terrorist attack are held, has dropped from 242 to 91.

But congressional Republicans oppose transferring the remaining detainees into the U.S. court system. And the administration has struggled to find other nations willing to accept them.

The number of foreign prisoners held at Bagram has also been reduced. Of at least 67 non-Afghans held there in 2012, nearly all have since been sent back to their native countries, according to Afghan officials. The exact number of those left is unclear.

The cases of brothers Said Jamaluddin and Abdul Fatah and the Uzbek national, Musa Akhmadjanov, have been complicated by their refusal to be repatriated, out of fear they will be tortured. Under international law, inmates cannot be sent back to countries where they may be abused.

Brig. Gen. Dawlat Waziri, a spokesman for the Afghan Defense Ministry, said the three men have reported being so fearful of their native countries that they prefer to remain in Bagram. Attorneys for the men deny they want to stay in the prison, which has been linked to past acts of torture and ghastly unsanitary conditions. The attorneys say the best option is for them to be resettled in a third country.

Given Afghanistan’s lack of international clout, it is ultimately the U.S. government’s responsibility to resettle them, attorneys and human rights officials say.

“The onus should be on the Americans because they have had five years to deal with this and knew the guys had to be resettled,” Foster said. “There was no reason to give them to the Afghans. They should have either kept them in [U.S.] custody or released them, and they did neither.”

The State Department said that the U.S. government has considered several options for the detainees, including repatriation and resettlement, but that transferring them to Afghan custody has been judged the “best option available under all of the circumstances considered.”

It said in a statement that it continued to monitor the men’s welfare, but adding, “Since the detainees are now in Afghan custody, the Afghan government would need to address any specific security or humane treatment concerns that might arise.”

Waziri referred requests for further comment to the country’s National Security Council, which did not respond.

“Our ministry’s job is just to provide them accommodation, food and access to lawyers,” Waziri said.

Jamaluddin and Fatah are the sons of Mullah Amruddin, a longtime political dissident and Islamic leader in Tajikistan, a country that regulates Muslims’ religious observance.

Fearing persecution, the brothers left home in the early 2000s to study in seminaries in Iran and later Afghanistan, Foster said. In 2009, they were captured by U.S. forces during a raid on a suspected militant safe house in Afghanistan.

For years, there was no public record of their detention.

Then about a year ago, Kate Clark, a researcher and director of the Afghan Analysts Network, uncovered U.S. case files containing allegations that the brothers had confessed to membership in the Islamic Movement of Turkestan, a Muslim separatist group.

However, neither U.S. nor Afghan prosecutors have ever charged the men with any terrorism-related crimes, Foster said.

Last February, an Afghan court convicted the brothers of entering Afghanistan without a valid visa, Foster said. They were sentenced to a maximum of three years in prison, but the judge ordered their release because they had already spent at least five years at Bagram. An appellate court and Afghanistan’s Supreme Court have upheld that ruling.

“They have now already been in custody for seven years,” said Foster, adding that her clients say the heat is not turned on in the prison and they are served food covered in maggots. “Why do they need to be there? You could at least put them in a hotel.”

Akhmadjanov, the Uzbek, was a shopkeeper who fled his native country because authorities were harassing him for “growing a beard and looking Muslim,” said his attorney, Mohammad Zamir Zamani.

He traveled to Turkey, where he got married. But in early 2010, Turkish authorities expelled him because he did not have a Turkish visa, Zamani said.

When he entered Afghanistan’s Nimruz province, local security forces handed him over to U.S. troops, according to court documents.

According to Clark, of the Afghan Analysts Network, U.S. authorities allege that Akhmadjanov then admitted to being a member of the Islamic Jihad Union and assisting foreign fighters in Afghanistan.

But Afghan courts have repeatedly ruled there was not enough evidence to suggest that Akhmadjanov — who claims an Afghan guard once bit him during an interrogation — had done anything illegal in Afghanistan.

“We have concluded to hand over the accused person to the officials of his country,” a three-judge appellate panel ruled in a written statement in May. “[If] the individual would feel threatened from [a] safety perspective, then we request application of international law for his safety and security.”

But Zamani said his attempts to get Akhmadjanov transferred out of Bagram have been stymied.

Akhmadjanov wants to be sent back to Turkey, to reunite with his wife. But Turkish officials can find no record of the marriage.

“We now hope to invite the Turkish girl to Kabul to marry him again,” Zamani said.

But that wedding will be possible only if U.S. authorities do more to help, he added.

“They are the ones with influence over Turkey,” Zamani said. “It would be much better if the Americans contact them instead of the Afghans.”

Julie Tate in Washington contributed to this report.

Read more:

In milestone, Guantanamo population to fall below 100 for first time in 14 years

Issue of where to move Guantanamo detainees threatens closure plan

Today's coverage from Post correspondents around the world