WASHINGTON - A federal judge ordered the U.S. administration Tuesday to free immediately 17 Chinese Muslims from Guantanamo Bay into the United States, a dramatic ruling that could set the course for releasing dozens of other prisoners from the U.S. naval facility in Cuba.

The administration criticized the decision as a threat to national security and quickly moved to block the decision in federal appeals court. "Today's ruling presents serious national security and separation of powers concerns and raises unprecedented legal issues," said Justice Department spokesman Brian Roehrkasse.

In a stern rebuke of the government, U.S. District Judge Ricardo M. Urbina said it would be wrong to continue holding the detainees since they no longer are considered enemy combatants. Members of the ethnic group known as Uighurs, the men have been in custody for almost seven years.

Over the objections of government lawyers who continued to cast the Uighurs as possible terror threats, Urbina ordered them to be released, in Washington, by Friday. It was the first court-ordered release of Guantanamo detainees since the prison camp opened in 2002.

"Because the Constitution prohibits indefinite detentions without cause, the continued detention is unlawful," Urbina said, prompting cheers and applause from local Uighur residents and human rights activists packed into the U.S. District courtroom.

Urbina, who was appointed to the bench by former president Bill Clinton, also ordered a hearing next week to decide where the Uighurs should be settled permanently. Until then, members of the Uighur community in the Washington area agreed to sponsor and help care for them.

"I think the moment has arrived for the court to shine the light of constitutionality on the reasons for the detention," he said.

Justice Department lawyer John C. O'Quinn's requested delay in the Uighurs' release pending possible appeal was denied Tuesday by Urbina, who said the detainees had waited long enough. Later Tuesday, Roehrkasse said the government would seek to block the order in appeals court, alleging that the Uighurs had received weapons training at camps in Afghanistan.

"Although the United States no longer treats these Uighurs as 'enemy combatants' of the United States and has been seeking to transfer them out of Guantanamo Bay ..., the government does not believe that it is appropriate to have these foreign nationals removed from government custody and released into the United States," Roehrkasse said.

Urbina said once the detainees arrived in Washington, they would be free to move around unsupervised, drawing the surprise of government lawyers who suggested that immigration officials might act to take the men into custody upon their arrival.

That prompted an angry response from the judge, who said he would not "take kindly" to such a government move. "That would be inappropriate," Urbina said. "There is a pressing need to have these people, who have been incarcerated for seven years, to have those conditions changed."

At issue is whether a federal judge has the authority to order the release of Guantanamo prisoners who were unlawfully detained by the United States and cannot be sent back to their homeland. The Uighurs, Turkic-speaking Muslims in western China, have been cleared for release from Guantanamo since 2004 and ordinarily would have been sent home.

Wang Baodong, spokesman for the Chinese Embassy in Washington, reiterated Beijing's argument that the Uighurs are terror suspects and should be returned to China. "We ask the U.S. side to take into serious consideration of the repeated requests of the Chinese side, and handle the issue in a prudent way so as not to further harm their bilateral co-operation on combating international terrorism," Wang said.

President George W. Bush's administration has refused to turn the Uighurs over to China because they might face torture. The administration says it has found no other country willing to accept them. Albania accepted five Uighur detainees in 2006 but since has balked at taking others, partly for fear of diplomatic repercussions from China.

Uighurs are from Xinjiang, an isolated region that borders Afghanistan, Pakistan and six Central Asian countries, and say they have been repressed by the Chinese government. China has long said insurgents are leading an Islamic separatist movement in Xinjiang. The Uighur detainees were captured in Pakistan and Afghanistan in 2001.

Urbina's decision has broader implications for the future of the Guantanamo prison, which the Bush administration has said it wants to shut down after "working with other countries to take people back under the right circumstances."

A federal judge is set to hold hearings this month on other Guantanamo prisoners challenging their detentions as so-called enemy combatants.

Roughly 20 per cent of about 250 detainees who remain at the military prison fear torture or persecution should they return to their home countries, according to the New York-based Center for Constitutional Rights. Their concerns raise similar questions as to where they should go if other countries refuse to take them. The United States has long maintained they should stay at Guantanamo.

"How many times does the Bush administration need to be told that detainees are entitled to essential rights? All the remaining detainees in Guantanamo Bay must be either charged and tried or released immediately," said Larry Cox, executive director of Amnesty International USA.