Police can take DNA samples from those under arrest the same as they take fingerprints and photographs, the Supreme Court said in a 5-4 decision on Monday.

The ruling defied the court’s traditional ideological divisions.

Justice Stephen Breyer, a more liberal justice, joined most of the court’s conservative bloc in the majority. Justice Antonin Scalia, an ardent conservative, joined three liberals in the dissent.

The majority upheld a Maryland law allowing police to take DNA swabs from people who are charged with violent crimes, as long as they have probable cause for an arrest.

The case involves Alonzo King, who was arrested in 2009 on charges of first-degree assault. Police took a DNA sample and matched his DNA to an unsolved rape. King was tried and convicted in the rape but sued to have the DNA evidence suppressed.

He said taking a DNA swab without a warrant violated his Fourth Amendment protections against unreasonable search and seizure.

The Supreme Court said DNA is identifying information just like fingerprints and can be collected at the time of an arrest.