The ruling in favor of detainees and news media outlets means some judicial records in the cases involving Guantanamo detainees could become public on July 29, a deadline set by Monday's ruling.
The government had tried to designate all of its responses in cases seeking indefinite detention -- whether classified or not -- as protected from public disclosure.
A detainee walks inside an open-air yard at the U.S. prison at Guantanamo Bay, Cuba, on May 31, 2009.
In his ruling, U.S. District Judge Thomas F. Hogan said the government request was too broad.
"The government's motion attempts to usurp the court's discretion to seal judicial records," the ruling said.
"Moreover, the public has a limited First Amendment and common law right to access the factual returns," it added, referring to documents filed in response to habeas corpus petitions.
While denying the government motion, the ruling gives the government until July 29 to determine what information in the factual returns is classified and therefore can be protected from disclosure.
"Today's decision is a victory for transparency," said Jonathan Hafetz, an attorney with the American Civil Liberties Union's National Security Project."For far too long, the government has succeeded in keeping information about Guantanamo secret, and used secrecy to cover-up illegal detention and abuse.
"The decision marks an important step towards restoring America's open court tradition that is essential to both accountability and the rule of law," Hafetz said.
News media organizations that joined the case were The Associated Press, The New York Times and USA Today.