A judge on Monday overturned Sheriff Alex Villanueva’s controversial decision to reinstate a deputy who had been fired for violating department policies on domestic violence and lying — a dispute that sparked a rare legal battle among some of L.A. County’s most powerful elected officials.

Los Angeles Superior Court Judge Mitchell L. Beckloff issued a preliminary injunction that says Villanueva must remove the deputy, Caren Carl Mandoyan, from his job. Mandoyan also must return county property, including his gun and badge.