Scalia blasted the assertion that DNA collection is primarily for identification, saying it "taxes the credulity of the credulous." It took days for authorities to collect King's swab and months to have it entered into a database.

If the process of identifying someone includes finding out what unsolved crimes he or she has committed, Scalia wrote, then it is "indistinguishable from the ordinary law enforcement aims that have never been thought to justify a suspicionless search."

"Solving unsolved crimes is a noble objective, but it occupies a lower place in the American pantheon of noble objectives than the protection of our people from suspicionless law-enforcement searches," he wrote.

But Gansler said civil libertarians "should be rejoicing at this opinion," saying it helps solve crimes that might never be solved otherwise and exonerates the wrongly accused.

O'Malley, who has been a major proponent of DNA collection, said in a statement that the ruling "confirms an important weapon in our arsenal to fight violent crime in our state."

Mercer, of the state public defender's office, said that just because the tool has been effective does not mean it conforms with the Fourth Amendment, and challenged Gansler's comparison of DNA to fingerprints.

"If the state wants to play the fingerprint game, the very same rule that controls fingerprints would mean DNA collected to investigate someone requires a warrant or probable cause," Mercer said.

Of the states that have laws similar to Maryland's, 13 limit DNA collection to those arrested for a felony, while the others limit it to those accused of certain felonies, according to Jayann Sepich, who runs a nonprofit called DNA Saves that advocates for DNA collection laws.

She described Monday's ruling as "incredibly important" because, she said, DNA collection laws can solve crimes and prevent repeat offenders from committing further offenses.

There are 1.3 million arrested suspects and 10 million convicted people nationwide whose DNA has been collected, according to FBI data.

In Maryland, law enforcement is authorized to collect a DNA sample when a suspect is arrested for committing or attempting to commit a violent crime or burglary.

In 2011, the last year for which data are available in Maryland, DNA was taken from more than 10,500 people arrested for committing or attempting to commit a violent crime. Those samples have matched evidence for 78 unsolved crimes and led to nine convictions. If the suspect is not convicted, the sample must be destroyed.

State lawmakers first established a DNA database in 1994 that included genetic information from individuals convicted of rape and sexual offenses, expanding the database in 2002 to include all felons. Samples from the arrestees were included in 2009.

In the most recent legislative session, Maryland lawmakers voted to keep the state DNA collection on the books indefinitely.

In a radio interview in early May, Gansler had predicted the Supreme Court would rule 9-0 in favor of Maryland's law, according to a transcript. It is unusual for a Supreme Court justice to read a dissent from the bench and can indicate a deep division among the justices.

Kennedy, Roberts, Stephen Breyer, Samuel Alito and Clarence Thomas made up the majority opinion; Scalia, Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan dissented.

Del. Sam Arora, a Montgomery County Democrat who is a member of the House Judiciary Committee, led a bipartisan group of 19 state legislators urging the Supreme Court to review the Court of Appeals ruling and support the state's law.

"Our law has taken rapists and other dangerous offenders off Maryland's streets," Arora said in a statement. "Today's decision upholds a proven tool that catches serial criminals and keeps innocent people out of prison."

Reuters contributed to this article.

jfenton@baltsun.com