(Reuters) - A federal appeals court on Tuesday said police officers cannot stop and search vehicles belonging to out-of-state motorists simply because of where they reside, including states where marijuana use is legal.

By a 2-1 vote, the 10th U.S. Circuit Court of Appeals in Denver said two Kansas Highway Patrol officers violated the constitutional rights of Colorado motorist Peter Vasquez in December 2011 by pulling him over and searching his car after he had been driving alone at night on Interstate 70.

The officers relied heavily on Vasquez’s residency to justify the search, which uncovered nothing illegal, saying Colorado was a known “drug source” where marijuana is legal.

But the court said that would justify searching motorists from the 25 U.S. states that permit marijuana use for medical purposes, and the four states, including Colorado, plus Washington, D.C., where recreational use is allowed.

“It is time to abandon the pretense that state citizenship is a permissible basis upon which to justify the detention and search of out-of-state motorists, and time to stop the practice of detention of motorists for nothing more than an out-of-state license plate,” Circuit Judge Carlos Lucero wrote.

“Absent a demonstrated extraordinary circumstance, the continued use of state residency as a justification for the fact of or continuation of a stop is impermissible,” he added.

The decision revived Vasquez’s civil lawsuit seeking damages from officers Richard Jimerson and Dax Lewis for violating his Fourth Amendment right against unreasonable searches. A lower court judge had dismissed the case in November 2014.

Chief Judge Timothy Tymkovich dissented, saying the case was a “close call” but that reasonable officers might have thought Vasquez’s travel plans suspicious and the search acceptable.

Jennifer Rapp, a spokeswoman for Kansas Attorney General Derek Schmidt, said he intends to ask the entire appeals court to review the panel’s decision.

Vasquez, now 37, said in a telephone interview that the decision shows that “police officers shouldn’t be able to do whatever they want” because they wear badges.

“I’m ecstatic,” said Vasquez, who now lives in San Antonio.

The 10th Circuit decision applies in Colorado, Kansas, New Mexico, Oklahoma, Utah and Wyoming.

The case is Vasquez v Lewis et al, 10th U.S. Circuit Court of Appeals, No. 14-3278.