Angel Miralda was proud of his 320 solar panels in a field near Benabarre, in northern Spain. They added 56 kilowatts of clean-energy capacity to a country that depended on oil imports. The panels cost 500,000 euros ($735,000): 150,000 euros <WC>came <WC1>from an early retirement payoff from IBM's Barcelona office, the rest from a bank loan. The government promised a 10 percent annual return on such projects. That was in 2008.<WC>

<WC1>Five years later, after subsidies were cut on July 12 for the third time since 2012, his income is down by 40 percent, and he is struggling to repay the loan.

<WC>"<WC1>There is no legal security in Spain," he complains.

Miralda is the victim of a bungled, overambitious renewables program.

Governments everywhere want to turn green and create environmentally friendly jobs. But as Spain shows, good intentions are not enough. If the policies are wrong, the benefits are wasted, the jobs disappear, the costs remain <WC>—<WC1> and business investors bear the brunt.

In 2007 Spain had just 690 megawatts of installed capacity of solar photovoltaic, or PV, panels. That was the year global PV prices started to fall, thanks to booming production in China. Hoping to stimulate a new green industry, for which sunny Spain seems ideal, the government increased the prices it paid for solar power to 12 times the market price for electricity.

In a sense, it worked spectacularly. According to research by CF Partners, a carbon-trading firm, solar PV capacity rose fourfold in 2008 alone.

Another technology for capturing the energy of sunlight, solar thermal, also grew hugely, albeit more slowly because it takes longer to deploy. Its installed capacity rose from 11 megawatts in 2007 to 1,950 megawatts now.

Renewable-energy output doubled between 2006 and 2012. At that point, Spain had the fourth-largest such industry in the world.

But costs exploded, too. Subsidies to renewable energy rose from 193 million euros in 2007 to 8.1 billion euros in 2012 (a 40-fold increase).

Since the government was unwilling to pass the full costs on to consumers, the cumulative tariff deficit (the cost of the system minus revenues from consumers) reached 26 billion euros, having risen by about 5 billion euros a year.

This would have been unaffordable at the best of times: 8 billion euros is almost 1 percent of gross domestic product. But as the euro crisis overwhelmed Spain's finances, reform of the renewable-energy bonanza became inevitable. On July 12, the government unveiled its latest cuts. It lopped 2.7 billion euros off the subsidy bill, on top of the 5.6 billion euro cuts that (calculates Acciona, a construction firm) it has already imposed in 2011-13.

The changes have turned renewable energy into a fully regulated business.

Companies used to be able to choose between getting market prices plus a premium, or to agree on long-term contracts that guaranteed a set margin above their costs. The government scrapped the first option earlier this year and has now scrapped the second. Instead, it will estimate the value of companies' assets and cap their pre-tax profits at 3 percentage points above 10-year Spanish government-bond yields. (How this will work in practice has not been announced.)<WC>

<WC1>The changes have infuriated everyone. They are retroactive <WC>—<WC1> affecting current operations as well as new ones <WC>—<WC1> so there will be a deluge of lawsuits challenging their legality. Some firms will face problems servicing their debt, and the government is in talks with banks to forestall bankruptcies. Outstanding loans for renewable energy are reckoned to be 30 billion euros. Five of the biggest utilities estimate that the reforms will jointly cost them 1 billion euros a year. The share prices of companies most affected <WC>—<WC1> Iberdrola, EDP Renewables and Acciona <WC>—<WC1> nosedived.

It has been a chastening experience. The government failed to cut subsidies when renewables were booming, so the cuts have had to be Draconian. It imposed no cap on new capacity and stood by while that grew uncontrollably (this also happened in Germany). The promised jobs have vanished. The solar energy business has lost tens of thousands of jobs from its peak. And after repeated retroactive cuts, no one is willing to invest in renewable energy anymore.<WC>

<WC1>Yet because projects often receive subsidies for 20 years, the costs remain. Even after the cuts, renewables subsidies are running at 7 billion-8 billion euros a year. It is not hard to think of better ways of spending such large sums of taxpayers' money.

<i>From the Economist magazine.</i>