A crime-fighting robot dubbed “K9″ — which patrolled a homeless encampment in San Francisco — was “fired” after locals knocked it over and smeared it with feces.

Residents raged against the SPCA-backed machine, which was rolled out to fight crimes originating in the enclave near an animal shelter in the Mission District.

In the last month, the robot was battered with barbecue sauce, smeared with feces, covered by a tarp and toppled over by an attacker, according to the Washington Post.

The SPCA finally called it quits last week, announcing the mechanical crime-fighter had to go.

“Effective immediately, the San Francisco SPCA has suspended its security robot pilot program,” said Jennifer Scarlett, the organization’s president. “We piloted the robot program in an effort to improve the security around our campus and to create a safe atmosphere for staff, volunteers, clients and animals. Clearly, it backfired.”

SPCA officials said the robot was hired to patrol outside their animal shelter after two break-ins.

K9 was able to snap images, record security footage and notify shelter employees or police in case of an emergency.

The organization denied multiple news reports that the robot was put in place to get rid of the homeless, but still received hundreds of messages threatening violence and vandalism against their shelter, they said.

The R2D2-resembling machine was rented from Silicon Valley startup Knightscope, which referred to accusations that it targeted the homeless as “sensationalized reports.”

But local vagrants disagreed.

“We called it the anti-homeless robot,” John Alvarado, who camps near the animal shelter, told the UK’s Guardian.

“We started feeling like this thing was surveying us for the police,” said another vagrant, Lexi Evans, whose whole tent encampment has now moved around the block outside another business. “That’s officially invasion of privacy. That’s uncool.”

The Golden State has the largest homeless population in the US with an estimated 118,142 living there in 2016, according to the Department of Housing and Urban Development.