Albert Florence said he was subjected to what he called a pair of intrusive, humiliating searches six years ago.

But Justice Anthony Kennedy, writing for the court, said the policy was designed in part to protect the safety of Florence and other inmates.

"Exempting people arrested for minor offenses from a standard search protocol thus may put them at greater risk and result in more contraband being brought into the detention facility," said Kennedy. "This is a substantial reason not to mandate the exception (Florence) seeks as a matter of constitutional law."

Chief Justice John Roberts and Justices Antonin Scalia, Clarence Thomas, and Samuel Alito supported all or part of Kennedy's opinion.

Florence was challenging Burlington County rules allowing routine strip searches of everyone arrested, even for minor offenses, regardless of the circumstances.

The man was a passenger in his family's sport utility vehicle when it was stopped by a New Jersey state trooper in March 2005. His then-pregnant wife was driving and their 4-year-old son was in the back seat as they headed to a Sunday dinner.

Since Florence was the vehicle's registered owner, the officer ran his identification and discovered a bench warrant for an outstanding fine. He had already paid the fine and carried a letter attesting to that fact, since he claimed he had been stopped on several previous occasions. Nevertheless, the 35-year-old Bordentown resident was handcuffed and arrested, then taken to the jail in Burlington County, in the central part of the state.

Court records show Florence was subjected to an invasive strip and visual body-cavity search. He was then held for six days in the county lockup before being transferred to a Newark correctional facility, where, he claims, he was subjected to another more intrusive search before being placed in the general prison population.

"It was very disgusting. It was just a bad, bad experience," he told CNN's Kate Bolduan recently. "I was just told, 'Do as you're told.' Wash in this disgusting soap and obey the directions of the officer who was instructing me to turn around, lift my genitals up, turn around, and squat."

The next day a magistrate freed Florence, confirming what he had insisted all along, that the fine had been paid.

Florence then sued, claiming the search protocols violated his Fourth Amendment rights, since neither jail reasonably suspected he presented a security threat, or was smuggling contraband. But a federal appeals court in Philadelphia last year ruled the blanket search policy proper.

"The 5-4 decision was as close as we could get with excellent dissent in this political climate of recent law for indefinite detention of citizens without trial that shaves away our constitutional rights every day," said Susan Chana Lask, Florence's New York-based attorney. "Politics and the Constitution should not be mixed."

Kennedy said this ruling was limited, and that the court need not consider other more invasive prison searches, such as those involving touching an inmate, and for those detainees held in solitary confinement.

In dissent, Justice Stephen Breyer said, "I cannot find justification for the strip search policy at issue here -- a policy that would subject those arrested for minor offenses to serious invasions of their privacy."

Another one of Florence's lawyers, Thomas Goldstein, had urged the court to rely on earlier precedent forcing jailers to use individualized discretion before searching inmates. "If the jail has the facts, as it did here, to affirmatively determine that there is no reasonable suspicion, which is what they decided about Mr. Florence," he said, "then it is an extraordinary intrusion on dignity and autonomy to strip him naked when they have no reason to do so."

But the county's attorney, Carter Phillips, said prison officials know their security system best. Noting that jail is "without question one of the most dangerous, most risky environments," he said he hoped the court would not ask "individual jailers to make decisions where they clearly will not have the kind of information" they would need and "where if they make a judgment wrong in either direction, all it means is litigation."

Federal courts before the September 11, 2001, terror attacks had been at odds over the constitutionality of strip searches. The Constitution's Fourth Amendment protects against "unreasonable searches and seizures."

The Supreme Court in 1979, in what is called the Bell precedent, upheld the kind of search Florence had undergone for prisoners who had contact visits with outsiders. Using a balancing test, the justices said the prison's security interest justified intrusion into the inmates' privacy. But subsequent appeals courts have found those arrested for minor offenses may not be strip searched unless authorities have a "reasonable suspicion" that the person may be concealing a weapon or contraband such as drugs.

In 2008, however, appeals courts in Atlanta and San Francisco found searches of every inmate coming into the prison population are justified, even without specific suspicions. Those opinions were the first of their kind since the 9/11 attacks and, along with Florence's case, now give the high court the chance to clarify an issue that a number of civil and human rights proponents have tried to highlight.

Local jails in New Jersey at the time of Florence's arrest were subject to federal monitors after allegations that minority motorists and their passengers were being unfairly targeted for police stops and arrests, sometimes called "racial profiling." Stops of that nature are not at issue in the current appeal. Florence, who is African-American, is not alleging any racial discrimination by the state or individual officers.

The case is Florence v. Board of Chosen Freeholders of the County of Burlington, New Jersey (10-945).