For now, electricity generation from the sun’s rays needs to be subsidized because it requires the purchase of new equipment and investment in evolving technologies. But costs are rapidly dropping. And regulators are still learning how to structure stimulus payments so that they yield a stable green industry that supports itself, rather than just costly energy and an economic flash in the pan like Spain’s.

Image Puertollano, a mining center, has wooed the solar industry. Credit... The New York Times

“The industry as a whole learned a lot from what happened in Spain,” said Cassidy DeLine, who analyzes the European solar market for Emerging Energy Research, a firm based in Cambridge, Mass. She noted that other countries had since set subsidies lower and issued stricter standards for solar plants.

Yet, despite the pain that Spain’s incentives ended up causing, in many ways they fulfilled their promise, Ms. DeLine said.

“Even though incentives can create bubbles and bursts, without them this industry won’t take off,” she said. “The U.S. is really behind Europe on this, and if we wait until solar is cost-competitive on its own, we may miss the boat and an opportunity to shape the market.”

The most robust Spanish solar companies survived the downturn, have restructured and are re-emerging as global players.

For example, when the government changed course, Siliken Renewable Energy, originally a producer of solar panels, shut its factories for five months and cut its staff to 600 from 1,200. But after shifting its focus to external markets like Italy, France and the United States, and diversifying into solar support services, the company now turns a profit.

“We were a company that banks trusted, so we could make the shift,” said Antonio Navarro, a company spokesman. “But a lot of little companies disappeared.”