Ayaz was 15 when he traveled to Afghanistan, from his native Pakistan, to take a job in a restaurant.

He had been there a few weeks when American soldiers entered, asked for him by name, and took him away. That was in 2004. It was the start of a six-year nightmare. Ayaz was held first at a military base, and then at the notorious Bagram prison. To this day, he does not understand why he was detained, but believes a co-worker falsely accused him of being a terrorist in exchange for a reward.

During his imprisonment, he had little access to justice. “They said that I was a suicide bomber and that I want to bomb the USA,” he said. “I had a representative who was not a lawyer. He would often make my case worse.” In 2011, Ayaz was repatriated to Pakistan. He claims he had been cleared two years earlier, after US officials determined that he was not a combatant and there were no grounds to hold him.

Ayaz, now in his early 20s, lost six years of his life, but he was one of the lucky ones. Of the 3,000 prisoners currently held at Bagram prison, there remain around 67 foreign nationals, who are caught in a legal black hole and held without charge, trial or even access to a lawyer. As the US prepares to withdraw from Afghanistan in 2014, the question of what will happen to this notorious prison is becoming more pressing. Is it about to become the next Guantanamo?

The prison is the largest of the detention centers opened by the US as part of its military operations in Afghanistan. Located around 60 kilometers north of Kabul, it gets its name from the Bagram Air Base, to which the original site was adjacent. The prison came into use soon after the US invaded Afghanistan in 2001, but in 2004—because of difficulties detaining extra prisoners at Guantanamo Bay—it became the primary detention site for suspected militants and terrorists. This included Afghans and non-Afghans captured as part of the war on terror. By 2008, it held 630 detainees, double the numbers held at Guantanamo. With resources under strain, it was replaced by a permanent facility at Parwan in 2009, where the several thousand prisoners now reside. (Its official name is the Detention Facility in Parwan (DFIP), but the prison is still colloquially referred to as Bagram.)

The US is preparing to withdraw all troops from Afghanistan, and it does not particularly want to retain a detention facility in the country. With great fanfare, control of Afghan detainees was handed over to the Afghan authorities earlier this year, but the foreign nationals being held at the prison still pose a problem.

Each case involving a foreign national requires lengthy, bureaucratic repatriation negotiations between the US and the receiving country. Discussions between Pakistani and American authorities regarding prisoners at Bagram have stretched on for years; some of the detainees still held at the facility were cleared for release as far back as 2010, but remain stranded there. Two sticking points are ensuring their safety: under international law, the US cannot send detainees to countries where they are likely to be tortured, and it must ensure that any threat they pose to security is sufficiently mitigated.

If that sounds familiar, it is because it is the same set of problems that have prevented the closure of Guantanamo Bay. Congress has imposed burdensome restrictions on repatriation, making it very difficult to close these prisons. In May this year, President Obama remarked: “I transferred 67 detainees to other countries before Congress imposed restrictions to effectively prevent us from either transferring detainees to other countries or imprisoning them here in the United States.”

Around two-thirds of the 67 non-Afghan prisoners are Pakistani, like Ayaz. None of them have been formally tried, although every six months they face a review of their case by a US administrative board. The US claims that some are Al-Qaeda operatives who were arrested in the aftermath of 9/11. That means some of them have been held since 2002: more than a decade without charges or trial.

The miscarriages of justice are many and various. Some, like Ayaz, have been held on little or no evidence. One detainee was just 14 when he was arrested in 2008.

“We know that Bagram Prison is going to remain open after the US pull-out,” says Omran Belhadi, a lawyer and caseworker for Justice Project Pakistan (JPP), a non-profit group representing some of the Pakistani prisoners. “Last October the Pakistani government announced the return of six Pakistani citizens. After 11 months, they are nowhere to be seen. If it takes over a year to repatriate six men, how long will it take to repatriate the remaining 34?”

The detainees caught in a bureaucratic nightmare will attest to the process being painfully slow. Yasir is a 31-year-old from Balochistan, a province in southwest Pakistan. In 2004, he was living in Iraq and working in real estate. He was captured by British forces, and handed over to the US military. In 2010, after six years of detention at Bagram, he was recommended for repatriation to Pakistan, but this repatriation never materialized, and he remains at the prison. Every six months, he attends a hearing. Every time, the review board recommends him for transfer. And every time, the transfer fails to materialize.

Yasir is frustrated. He says that since he was first recommended for a transfer three years ago, "nothing changed in my case or in my manners. I still have good behavior.” In short, he cannot understand why he remains in Afghanistan.

A comprehensive report by JPP holds both the American and Pakistani governments to task for failing to place enough priority on finding a resolution. The report says both governments have failed to adopt clear, consistent policies on repatriation, that the Pakistani authorities have not pushed hard enough, and that the US has “placed little priority on resolving these detainees' cases … and has tended to overstate the potential security risks that detainees pose."

It is now just a matter of months before the scheduled US withdrawal from Afghanistan, and with the clock ticking, it seems highly likely that the prison will stay open, and at least partially under US control. The Afghan government has little desire to take on the responsibility for these lengthy negotiations over foreign nationals. Conversely, the US cannot guarantee the prisoners will not face ill-treatment if control of the prison is transferred to Afghanistan.

So is this another Guantanamo in the making? Unless governments develop the political will to prevent such an outcome, it seems inevitable that these prisoners will, indeed, be caught in the same nightmarish limbo between detention and freedom. The JPP report recommends that the Obama administration resist Congress' attempts to politicize the repatriation of Pakistani detainees, that it prevent Congress from placing burdensome restrictions on the repatriation process, and that it commits to providing due process for these detainees and bringing an end to their detention before the US military withdrawal. Yet there is currently nothing to indicate that any of these recommendations will be followed.

Guantanamo is internationally known and oft-discussed in the West. Its mere name is enough to conjure up images of the worst of US foreign policy and the injustices of the war on terror. Obama has acknowledged that it is “a symbol around the world that America flouts the rule of law.”

During the US-Afghanistan war, Bagram was the site of several high-profile scandals over the torture and abuse of prisoners, with two detainees beaten to death in 2002. The prison may be less famous in the West, but there can be no doubt that its continued presence is having a devastating effect on America’s already tarnished image in the Middle East and South Asia.

“In Afghanistan, Bagram has long symbolized the US occupation and its excesses,” says Belhadi. “Torture, Qur’an burning, and administrative detention is what Afghans remember Bagram for. It is yet another example of the United States ready to trample basic human rights to achieve short-sighted political goals.”

Obama has focused his energies on ending George W Bush’s wars in Iraq and Afghanistan, but while these prisons remain open, it will be impossible to consign these injustices to the past.