The wind farms near the north-eastern Spanish town of La Muela generate €1m a year in rent and local taxes, providing generous funding for elaborate building projects and subsidised holidays. Photograph: Sipa Press/Rex Features

Powerful wind turbines churned the air above La Muela last week but the stir in this small Aragonese town was caused by the arrest of the mayor and 18 other people on charges that reveal a new phenomenon in Spain: eco-corruption.

Windswept La Muela, with its 500 giant windmills, has become one of Spain's richest towns on the back of what is the new gold for rural communities - renewable energy. Eight years ago, the wind energy companies that provide up to 40% of Spain's electricity on blustery days came looking to plant their turbines. These now line the hills outside the town and form neat patterns across the plain.

Generating companies pay €1m (£940,000) a year to the town hall in rent and taxes. Private landowners, many of whose families worked the hard, unforgiving land for centuries, share a further €0.5m a year. Planting windmills has proved far more lucrative than cultivating crops. Each brings in about €3,000 a year to the landowner.

The wind energy boom brought with it a frenzy of development, as the town's population increased threefold. With wind power pouring euros into the municipal coffers, colossal building schemes were pursued. The 5,000 residents now share three museums, a theatre, a bull-ring and a gleaming sports and swimming centre.

The mayor, María Victoria Pinilla, who denies any wrongdoing, showered townsfolk with money. She subsidised holidays to Cancún, Mexico, to Brazil, and to the Caribbean beaches of Santo Domingo. She herself was among those to prosper. A plot of land she owns now contains three smart new houses for herself and her two sons, one of whom was also arrested last week.

In a pattern repeated in several Spanish towns recently, Pinilla's arrest provoked indignation, directed not at her but at the courts and the police. "She has done fine things for La Muela," one local told the television cameras. "People are just envious."

Others were not so supportive. "She has been making fools of us for 22 years," said 42-year-old Asunción Gimeno.

The magistrate investigating the case yesterday sent La Muela town councillor Juan Carlos Rodrigo to jail to await trial. The same judge was expected to interrogate Pinilla today and decide if she, too, should be held in custody.

While it was the construction boom that accompanied the wind turbines which led to the arrest of Pinilla and other officials alleged to have demanded backhanders, the renewable energies explosion was already leaving a footprint of sleaze elsewhere in Spain.

A judge in the Canary Islands last week accused a former industry department chief, Celso Perdomo, of making millions of euros by selling secret information on land about to be earmarked for the wind industry.

Inspectors are also busy looking at a sudden boom in solar farms, where subsidies assuring a 12% annual return on investment over 25 years sent Spain's notoriously corrupt real estate developers into a frenzy.

In many ways those subsidies were a spectacular success. In three years Spain built about 29,000 solar "gardens", to become the world's second-largest producer of solar power after Germany. In 2004 it took three months to install 2 megawatts; by 2008 the same amount was being installed every day. The sector grew ninefold over two years, as stretches of countryside disappeared under shiny black panels. "Entire boatloads of panels from China were being auctioned before they even got to port," said one dealer.

Banks eagerly handed out loans. "It became an instrument for speculators," explained environmental expert Juanma Redondo. "Solar gardens were being sold like pension funds. It was a risk-free investment."

Licences to build solar gardens or connect to the grid became Spain's most sought-after pieces of paper, and backhanders and trafficking in licences soon started.

Clean energy is believed to have attracted dirty money, as the notoriously corrupt construction business sought ways to launder illegal earnings. Information about plans to build connection points to dump solar power into the grid also became hugely valuable: land prices around these points multiplied up to 10 times overnight.

"Who got the licences? That is where the shadow of doubt appears. There have been no public tenders and no transparent decision-making," commented Luis Gómez, a journalist at El País.

A dozen officials at the regional government of Castilla y León, in north-west Spain, were sacked last year after giving licences to relatives. Then José Joaquín Moya, the socialist mayor of Bigastro, eastern Spain, was arrested for allegedly selling licences.

When Spain's National Commission for Energy decided to inspect 30 solar gardens, it found only 13 of them had been built properly and were actually dumping electricity into the network. After exceeding its solar energy target 10 times over, Spain has slashed subsidies for future projects.

Despite the corruption brought by the boom, Spain is also reaping benefits. On sunny days solar panels provide up to 5% of the country's energy needs. Wind turbines like those at La Muela provide even more clean energy, allowing Spain to cover almost a third of electricity needs from renewable sources last month.