This reverses a lower court ruling last August that ordered the government to disclose the names of the detainees and their lawyers.
The case stems from the government's refusal to make public the names and other information about the detainees under a Freedom of Information request.
A coalition of groups including the Center for National Securities and the ACLU brought the lawsuit, reports CBS News Reporter Kathy Mountcastle.
In a 2-1 ruling, a panel from the U.S. Circuit Court of Appeals for the District of Columbia rejected arguments that the Justice Department should have publicly provided the names of detainees, names of their lawyers, dates they were picked up and the reasons why they were being detained.
The court affirmed that the information can properly be withheld from the public under an existing exemption from the Freedom of Information Act. That provision exempts information from disclosure if it is compiled for law enforcement purposes and if revealing it "could reasonably be expected to interfere with enforcement proceedings."
Earlier this month, a long-awaited oversight report by Justice Department investigators found the FBI took too long to determine whether hundreds of foreigners held after the Sept. 11 attacks were involved with terrorism, as dozens endured "lock-down" conditions 23 hours each day and slept under bright lights.
The inspector general's report found "significant problems" in the Bush administration's actions toward 762 foreigners held on immigration violations after Sept. 11. Only one, Zacarias Moussaoui, has been charged with any terrorism-related crime; 505 have been deported.
Last month, the Supreme Court upheld a Justice Department policy closing immigration hearings to the public.