SAN FRANCISCO — For the second time in recent weeks, a federal gun case has been torpedoed after a federal judge ruled that San Francisco police officers violated the defendant’s constitutional rights during a traffic stop.

In June, U.S. District Judge Charles Breyer granted a defense motion to suppress evidence seized from searches of a Chevy Yukon SUV and a storage unit belonging to Tei Mati, unearthing drugs and a shotgun. The U.S. Attorney’s office initially appealed Breyer’s ruling, but last week changed course and voluntarily dismissed the appeal, court records show.

In his ruling, Breyer found that San Francisco officers who pulled Mati over for a speeding violation illegally prolonged the traffic stop, and in so doing discovered that Mati was on probation with a condition allowing police searches. It is unconstitutional for police to stall out a traffic stop beyond its original purpose in order to conduct such a search.

“The officers’ extension of the stop to inquire into Mati’s probation status, and specifically whether Mati had a search condition, was unconstitutional,” Breyer wrote in his ruling. “The officers’ searches of the Yukon and the storage facility are therefore fruit of the poisonous tree.”

Federal prosecutors have not yet dropped the charges against Mati, but without evidence found during the illegal search, the case is likely hampered beyond all repair.

Breyer’s ruling is nearly identical to one issued in June by U.S. District Judge Jeffrey White, who wrote that an SFPD search during a traffic stop was unconstitutional because it had been prolonged and because officers’ misunderstood the law. That ruling resulted in a dismissal of gun charges against Carl Bernard, who was facing 10 years in federal prison.

The officer wrote in his report that because Bernard was on probation, he believed he could search Bernard’s vehicle and give him a pat down. But Bernard’s search clause permitted police searches only “based upon reasonable suspicion of contraband or a violation of the terms of supervised release,” not at the will of any law enforcement officer.

“If the SFPD is indeed training its officers that federal supervised release conditions routinely permit searches without reasonable suspicion or probable cause, that training simply is not accurate,” White wrote in his June ruling.