BERLIN — What Google wants, Google usually gets, but in Berlin’s Kreuzberg neighborhood, residents have won a battle against the internet giant, which backed away from a project in the face of local opposition.

Google had planned to convert an old electric company building in Kreuzberg into an incubator for tech start-ups, the kind of development that could have altered the fabric of the funky, multicultural area.

Instead, the company announced on Wednesday that after sinking millions of dollars into the project, it will make the space available, free of charge, to nonprofit social service and local advocacy groups — a move its adversaries welcomed.

The decision handed a surprise victory to anti-gentrification groups who had protested Google’s plan, but some city officials saw it as a lost economic opportunity and a stain on Berlin’s vaunted tech-friendly reputation.