ALGECIRAS, Spain—When driving through Don Quixote country in Spain’s Castille-La Mancha region, you are dazzled by the spectacle of wind farms proudly churning out the energy that will save Iberia and the planet, followed, once you cross into Andalusia, by solar farms and the green jobs of the future.

Except that if things continue as they are in Spain, the world’s poster child for renewable fuel, wind and solar energy may not save us after all—or renew the capitalist economy.

Spain is the third-largest producer of alternative energy, after the United States and Germany; if the relative sizes of its economy and population are taken into account, it is the largest. The first solar tower ever was set up near Seville. Next year wind and solar energy will account for 30 percent of Spain’s energy matrix. Its wind turbines are a technological wonder—the United States imports many of them.

But this achievement is not the result of people’s choices and the healthy interplay of producers and consumers. Rather, it is a political scheme combining protectionism, mandates and subsidies. A few months ago, a study by Gabriel Calzada of King Juan Carlos University caused an international uproar when it disclosed that each green job was costing Spanish taxpayers between 540,000 and 1 million euros, and entailed 2.2 jobs lost or not created because of the misallocation of capital. Despite 43 billion euros in subsidies, solar energy is still not a major component of the energy matrix, and Spain has not complied with the Kyoto Protocol on climate change.

Fiscal spending on green energy has created a financial deficit in the power industry as a whole, forcing the government to cut back 30 percent of handouts to the solar energy producers. Thousands of jobs have been lost—part of the country’s painful 19 percent unemployment rate. Because of the politically induced concentration on renewable fuel, other priorities, such as setting up new and better electrical grid connections with France, have been neglected.

Red Electrica de Espana, the government-owned company that runs the national power grid, has just put out a report admitting there is excess capacity in the wind power industry: 5 percent of Spain’s wind energy will be wasted in 2014 because of insufficient demand. Things are expected to get a lot worse in 2016, even allowing for the 3 million electric cars that Spanish authorities (optimistically) project for that year.

All of this is the result of politics displacing market forces. Starting in the 1990s and with particular vigor in the second half of this decade, the authorities geared a significant part of the nation’s resources toward goals that were entirely political in nature, even if motivated by lofty sentiments. The result—as is usually the case when political incentives give rise to bad investments—has been a bubble of sorts.

Spanish utilities are forced to buy all the wind energy available, while wind-farm operators receive a set price or sell at market prices and obtain a big premium. All renewable power operators have had to set up control centers connected to the national grid—the largest being Iberdrola’s, in Toledo, an impressive affair. Spain’s alternative energy industries amount, in essence, to a command economy.

The consequences of the government establishing a command economy for electricity could not have been different than those of other command economies elsewhere. There was indeed something Quixotic about the 300 percent growth experienced by Spain’s solar energy sector since 2005 and in the fact that about 500 companies got involved in wind farming, attracted by the siren song of captive markets and government largesse (now these companies are shedding jobs too.) Reality was bound to set in sooner or later.

Of course, the government-led rush to alternative energy has imposed heavy costs on competitors. The operators of combined cycle power plants, which run on natural gas, the cleanest fossil fuel, also find themselves with excess capacity due to plants they had built in anticipation of a demand that has been channeled by Madrid’s authorities toward wind. They are fighting back, asking the government to assume responsibility. It could get ugly.

The lessons of Spain’s renewable energy program ought to be taken into account at the upcoming Copenhagen summit on climate change. In recent years, many countries, including the United States, have touted the Spanish model as an inspiration. They really need to look again.