The German government today agreed to extend the working lives of its nuclear reactors by an average of 12 years, in a controversial move that will shape the energy strategy of Europe's largest nation for decades to come.

Having put the seal on a deal that was hammered out after lengthy talks between politicians and power companies, the German chancellor, Angela Merkel, hailed it as a "revolution in energy provision". She said it would help to ensure Germany's place at the forefront of "the most environmentally and worldwide most efficient" energy policy.

Under the agreement, the four power companies E.ON, RWE, EnBW and Vattenfall have agreed to pay the German government €30bn (£25bn) to allow the operating lives of its 17 nuclear plants to be extended. The companies will also pay €2.3bn in nuclear-fuel rods tax over the next six years, as well as an annual €300m for the next two years and €200m between 2013 and 2016 into a special renewable energy investment fund.

The decision marks a turnaround on the decision reached almost a decade ago under the Social Democratic (SPD) and Green party coalition of Gerhard Schröder to phase out nuclear power early in the next decade.

Sigmar Gabriel, leader of the SPD, said it was a "black day for energy policy", and accused the government of selling out to the energy lobby. "The security of the Germans has been sold to four large companies," he said. "Never before has the impression been given so shamefacedly that politics can be bought."

The decision could prove the government's hardest test yet, at a time when its popularity ratings are suffering. According to recent polls, most Germans are in favour of phasing out nuclear power as soon as possible. Experts have predicted that the issue could put new wind back in the sails of the Green party, which has pledged to reverse the decision if it gets into government.

Merkel now faces the tough challenge of trying to ensure that any draft law bypasses the Bundesrat, or upper house of parliament, where she lost her majority earlier this year.

Greenpeace energy expert Tobias Münchmeyer said extending the lives of the plants amounted to little more than "a pure monetary gift from the government", which "damages Germany while being of advantage to the companies". He said the decision would also lead to the production of "thousands of tonnes" of additional atomic waste, and with it, the problem of where and how to store it.

The conservative government in neighbouring Austria condemned the decision, referring to it as a "disappointment" and a "retrograde step" for energy policy. "Germany has simply made it easier for itself to keep its CO2 emissions down," said Austrian environment minister Nikolaus Berlakovich, who added that the future lay in renewable energies. "What's clear is that atomic energy is no answer to climate change and no sustainable way in which to reduce CO2 emissions," he said.

A protest against the decision has been scheduled for 18 September in Berlin.

But Merkel, who spent a week in August touring nuclear power plants and alternative energy producers, said it was precisely to ensure the embracing of renewable energy that she had agreed to keep nuclear power plants running for longer. She said nuclear power would be a "bridge" that would allow more time for reliable and affordable technologies to be developed. Merkel pointed to the renewable energy investment fund, whereby nuclear utilities will effectively pay part of their gains from the extension to develop renewable energy.

The decision was reached following a report that said Germany would not be able to reach to its goal of reducing CO2 emissions by 80% in 2050, compared to 1990 levels, if it abandoned nuclear power too soon.