Updated

In a setback for President Barack Obama, Democrats still controlling the House have approved legislation to prevent Khalid Sheikh Mohammed and other detainees at the military prison at Guantanamo Bay from being transferred to the U.S. for trials in criminal courts.

The Guantanamo ban was included in a huge catchall spending bill that passed the House Wednesday by a 212-206 vote. The Senate has yet to act on the legislation, which would further imperil Obama's effort to close the detention center for terrorist suspects.

The move comes after the first Guantanamo detainee to face a civilian trial, Ahmed Ghailani, was found guilty last month of just one of the hundreds of charges brought against him connected to attacks on two U.S. embassies in 1998.

Although Ghailani faces up to life in prison, Republican lawmakers pointed to the case as a reason to support military trials for the Guantanamo detainees.

Wednesday's vote would block alleged Sept. 11 mastermind Khalid Sheikh Mohammed from a trial in civilian court.

Critics of the administration's approach also argue that civilian courts are more likely to hand down acquittals than military courts because of more lenient rules of evidence and rights afforded to suspects.

The legislation goes beyond current law, which allows detainees to be transferred to the United States for trial but not to be released.

The provision is opposed by the Obama administration, which won some wins in the underlying budget bill such as money to implement the new nuclear weapons treaty with Russia and a signature education initiative.

When Obama took office almost two years ago, he pledged to close the prison by early this year. The promised soon unraveled amid resistance from Democrats and politically charged opposition from Republicans.

The transfer ban would apply until Sept. 30 — the end of the fiscal year.