MADRID—A growing number of Spaniards are abandoning the country's big electric utilities to form consumer cooperatives that generate or purchase power from renewable energy sources.

Their ranks—while still tiny—are being fed by consumer discontent over a government decision to curtail green-energy projects. The defections highlight the latest fallout from a broader debate over green energy now raging across Europe.

In...