Germany's coalition government has decided to extend the life span of the country's nuclear power plants by an average of 12 years, officials say.
Under the agreement, some plants will now remain in production until the 2030s, instead of being phased out by 2021 as the previous government wanted.
There will also be new fees on utility companies to fund renewable energy.
Chancellor Angela Merkel argued that renewable sources are not developed enough to abandon nuclear power.
Ministers met until late on Sunday to discuss the plan, emerging to announce that the older of Germany's 17 nuclear plants will remain in production for eight more years beyond 2021 while more recent ones will stay online for an additional 14 years.
The plan reverses a decision by the previous government - a coalition of the centre-left Social Democrats (SPD) and the Greens - to shut down Germany's nuclear power stations by 2021.
The agreement was reached at a long meeting at the chancellery between Chancellor Angela Merkel, Environment Minister Norbert Roettgen, Economy Minister Rainer Bruederle, Finance Minister Wolfgang Schaeuble and other leaders of the governing centre-right coalition after months of wrangling.
The coalition leaders also agreed that energy companies would pay a nuclear fuel tax intended to raise $3bn (£1.9bn; 2.3bn euros) annually and contribute to a special fund to boost development of renewable energy sources.
The big energy companies have opposed the tax and the special fund.
The agreement requires parliamentary approval, said German news agency Deutsche Presse Agentur
Opinion polls suggest a majority of Germans would support an end to nuclear power generation.