The ruling followed the ideological divide on the high court, with five conservatives supporting such searches and four liberals objecting.
The searches are "suspicionless" -- meaning officials do not have to have an indication that weapons, drugs or any other contraband is present.
Writing for the majority, Justice Antony Kennedy said, "The question here is whether undoubted security imperatives involved in jail supervision override the assertion that some detainees must be exempt from the invasive search procedures ... absent reasonable suspicion of a concealed weapon or other contraband. Correctional officials have a significant interest in conducting a thorough search as a standard part of the intake process. The admission of new inmates creates risks for staff, the existing detainee population and the new detainees themselves."
Kennedy also cited health reasons as well as gang identification, among other justifications.
Two members of Kennedy's majority, Chief Justice John Roberts and Samuel Alito, indicated that the searches can be conducted only if a prisoner is to be placed among other prisoners.
Joined by three other liberals, Justice Stephen Breyer said, "A strip search that involves a stranger peering without consent at a naked individual, and in particular at the most private portions of that person's body, is a serious invasion of privacy" needing serious justification.
The ruling came in the case of Albert Florence, who was arrested by a New Jersey state trooper who determined Florence was wanted on a bench warrant for failing to appear at a hearing to enforce a fine. Florence eventually was released once officials learned that the fine had been paid.
While at the jail, however, Florence said he "had to open his mouth, lift his tongue, hold out his arms, turn around and lift his genitals." At a second detention center, Florence, "like other arriving detainees, had to remove his clothing while an officer looked for body markings, wounds, and contraband; had an officer look at his ears, nose, mouth, hair, scalp, fingers, hands, armpits, and other body openings; had a mandatory shower; and had his clothes examined. [Florence] claims that he was also required to lift his genitals, turn around, and cough while squatting."
After he was freed Florence filed suit alleging constitutional violations, saying there should not have been such an invasive search unless officials suspected he had weapons or other contraband. A U.S. appeals court eventually ruled against him, and the Supreme Court agreed.
2014: The Year in Fashion [PHOTOS]
Man wanted for abduction of missing UVA student