The 5-4 decision applies to noncitizens who already have served their sentences and are awaiting deportation hearings. A conservative majority led by Chief Justice William H. Rehnquist said jailing those immigrants does not violate their constitutional rights.
However, a different majority on the court upheld immigrants' right to appeal the jailings.
The case predates the Sept. 11 attacks and the government's subsequent crackdown on immigrants but raises some of the same civil liberties questions about who may be detained and for how long.
The ruling came in the case of Korean immigrant Hyung Joon Kim, who was jailed one day after completing a three-year term for burglary and petty theft in California.
"Congress, justifiably concerned that deportable criminal aliens who are not detained continue to engage in crime and fail to appear for their removal hearings in large numbers, may require that persons such as (Kim) be detained for the brief period necessary for their removal proceedings," Rehnquist wrote.
Justices Sandra Day O'Connor, Antonin Scalia, Anthony M. Kennedy and Clarence Thomas joined Rehnquist in that part of the ruling.
The court acted in an appeal from the Bush administration, which defended a 1996 federal law that requires the government to hold foreigners convicted of a range of felonies pending detention proceedings.
The law does not allow for a bond hearing, at which an immigrant could try to win release pending a deportation hearing.
The 1996 law also expanded the list of crimes requiring deportation to include most felonies and nearly all drug crimes. The Bush administration said more than 75,000 criminal aliens have been detained under the law, which was signed by former President Clinton.
The government claimed detention is necessary to keep deportable criminals from fleeing underground rather than showing up for hearings they are almost sure to lose.
The majority of justices noted that Congress passed the law in response to "wholesale failure" of the Immigration and Naturalization Service to respond to rising crime among immigrants. The INS had an enormous backlog of cases in which people were convicted of crimes and could have been deported, but the INS had not acted promptly to do so, Rehnquist wrote.
"The INS could not even identify most deportable aliens, much less locate them and remove them from the country," Rehnquist wrote.
Rehnquist cited a 1986 study that showed 77 percent of people identified as deportable were arrested at least once more before their deportation hearings even began.
Justices John Paul Stevens, David Souter, Ruth Bader Ginsburg and Stephen Breyer dissented.
Stevens, Souter and Ginsburg argued that Kim is a legal resident of the United States, with more rights than an illegal immigrant. The government did not justify why it needs to keep Kim in jail, Souter wrote for the three.
"This case is not about the national government's undisputed power to detain aliens in order to prevent flight or to prevent danger to the community," Souter wrote. "The issue is whether that power may be exercised by detaining a still lawful permanent resident alien when there is no reason for it and no way to challenge it."
Breyer objected to the majority's assertion that Kim himself admitted his crime makes him eligible for deportation. Kim admitted no such thing, and should have the opportunity to make his case in a bond hearing, Breyer wrote.