By Lawrence Hurley

WASHINGTON (Reuters) - The U.S. Supreme Court on Monday ruled that a police officer in North Carolina lawfully stopped a car with a faulty brake light - and then found a stash of cocaine in the vehicle - even though driving with one working light is not illegal in the state.

In an 8-1 decision, the court ruled against Nicholas Heien, who had argued that the sandwich bag of cocaine found in the April 2009 search should not have been allowed as evidence when he was charged with drug trafficking because the Surry County Sheriff's Department sergeant had no valid reason to stop the car.

Heien, who consented to the search of the car after he was stopped, pleaded guilty and was given a maximum prison term of two years.

Chief Justice John Roberts wrote on behalf of the court that the officer's mistake in believing that it was illegal to drive with one working light was not sufficient to violate Heien's right to be protected from an unlawful search under the U.S. Constitution's Fourth Amendment.

Under court precedent, a vehicle stop is valid only if the officer has "reasonable suspicion" that the driver broke a law. The court concluded in the North Carolina case that "reasonable mistakes of law" like those made by the officer in question do not make a search invalid.

Roberts rejected the argument made by Heien's lawyers that such a ruling would dissuade police officers from learning the law. He wrote that an officer "can gain no Fourth Amendment advantage through a sloppy study of the laws he is duty-bound to enforce."

Justice Sonia Sotomayor was the sole dissenter, writing that the court was "further eroding the Fourth Amendment's protection of civil liberties in a context where that protection has already been worn down."

She said lower courts will have difficulties assessing in future cases when an officer's mistake was reasonable.

The case is Heien v. North Carolina, U.S. Supreme Court, No. 13-604.

(Reporting by Lawrence Hurley; Editing by Will Dunham)