A sharply divided US Supreme Court has cleared the way for police to take a DNA swab from anyone they arrest for a serious crime.

The 5-4 ruling narrowly endorsed a practise now followed by more than half the states as well as the federal government.

"Taking and analysing a cheek swab of the arrestee DNA is, like fingerprinting and photographing, a legitimate police booking procedure that is reasonable under the Fourth Amendment," Justice Anthony Kennedy wrote for the court's five-justice majority.

But the four dissenting justices said the court was allowing a major change in police powers, with conservative Justice Antonin Scalia predicting the limitation to "serious" crimes would not last.

"Make no mistake about it: Because of today's decision, your DNA can be taken and entered into a national database if you are ever arrested, rightly or wrongly, and for whatever reason," Mr Scalia said in a sharp dissent which he read aloud in the courtroom.

He added: "This will solve some extra crimes, to be sure. But so would taking your DNA when you fly on an airplane - surely the TSA must know the 'identity' of the flying public. For that matter, so would taking your children's DNA when they start public school."

Twenty-eight states and the federal government now take DNA swabs after arrests.

Monday's ruling specifically backed a Maryland law allowing DNA swabbing of people arrested for serious crimes.

The high court's decision reinstated a Maryland man's rape conviction, which came after police took his DNA during an unrelated arrest.

A Maryland court had said it was illegal for that state to take Alonzo King's DNA without approval from a judge, under the Fourth Amendment to the US Constitution, which protects citizens against unreasonable searches and seizures.

The American Civil Liberties Union said the court's ruling created "a gaping new exception" to the amendment.

"The Fourth Amendment has long been understood to mean that the police cannot search for evidence of a crime - and all nine justices agreed that DNA testing is a search - without individualised suspicion," said Steven R Shapiro, the group's legal director.

He added: "Today's decision eliminates that crucial safeguard. At the same time, it's important to recognise that other state laws on DNA testing are even broader than Maryland's and may present issues that were not resolved by today's ruling."

Maryland's DNA collection law only allows police to take DNA from those arrested for serious offences such as murder, rape, assault, burglary and other crimes of violence.

In his ruling, Justice Kennedy did not say whether the court's decision was limited to those crimes, but he did note that other states' DNA collection laws differ from Maryland's.

Justice Scalia saw that as a crucial flaw, saying: "If you believe that a DNA search will identify someone arrested for bank robbery, you must believe that it will identify someone arrested for running a red light."