WASHINGTON — A police officer can stop a car based on a mistaken understanding of the law without violating the Fourth Amendment, the Supreme Court ruled on Monday in an 8-1 decision.

The case arose from a traffic stop in North Carolina based on a broken brake light. But state law there required only a single working “stop lamp,” which the car in question had.

In an opinion by Chief Justice John G. Roberts Jr., the Supreme Court ruled that the officer’s mistake was reasonable and so did not run afoul of the Fourth Amendment’s ban on unreasonable searches and seizures.

The case concerned a 2009 traffic stop near Dobson, N.C., conducted by Sgt. Matt Darisse. The car’s owner, Nicholas B. Heien, who had been asleep in the back seat while a friend drove, consented to a search. Sergeant Darisse found a sandwich bag containing cocaine.