* Nuclear exit by 2022, brown coal by 2038
* First plant to close this year
* Germany is world's biggest brown coal producer
* See Factbox on Germany's brown coal sites (Recasts with quotes, detail, context)
By Michael Nienaber and Holger Hansen
BERLIN, Jan 16 (Reuters) - Germany is set to become the first country to drop both nuclear and coal power under a landmark agreement to compensate workers, companies and regional governments as it switches off brown coal-fired plants by 2038.
The government struck a deal worth more than 40 billion euros ($44.7 billion) in the small hours of Thursday morning with the premiers of Germany's coal-mining regions.
Once the heartland of Germany industry, the coal regions of North-Rhine Westphalia have fallen on hard times as traditional heavy industries have lost sway, while coal regions in the east have yet to fully shrug off the impact of four decades in Communist East Germany.
Designed to ensure Europe's largest economy meets its 2030 target for cutting greenhouse gas emissions, the exit will be accompanied by heavy investments in renewable energy.
"Germany, one of the strongest and most successful industry nations in the world, is taking huge steps towards leaving the fossil fuel era," Finance Minister Olaf Scholz told a news conference.
The decision marks a major turnaround for Chancellor Angela Merkel's conservative-Social Democrat coalition. It abandoned as unachievable a key emissions target shortly before taking office in 2017, only to change course after growing public concerns about climate change fuelled a surge in polls by the Green Party.
"These were tough negotiations," Environment Minister Svenja Schulze said. "But you can see the result - we are the first country that has a binding agreement to exit coal and nuclear power - and that's an important signal internationally."
Economy Minister Peter Altmaier said the legislation would be brought before parliament by the end of January.
The oldest, dirtiest plants, some dating back to the 1950s, will go first, starting with a 300MW plant in the Rhineland scheduled to close this year. Over the following 18 years, the remaining 29 will close.
"What we have here is a good agreement for climate protection because it makes it clear that we mean business," Altmaier told a news conference.
Caught on the hop when a series of unusually hot summers and the impact of Swedish schoolgirl Greta Thunberg's Fridays for Future movement caused public opinion to turn, the German government last year introduced a major climate package, which included economy-wide carbon pricing.
The government added on Thursday that carbon emissions certificates held by power stations would be cancelled after they close, a move that should cap emissions and drive up the prices for certificates traded under the European Union's scheme.
Analysts thought the impact on the coal market would be limited, since EU demand for coal has long stagnated in the face of competition from renewables and gas. Coal prices fell 40% last year and have barely recovered since.
COMPENSATION FOR ALL
The affected states of Brandenburg, Saxony and Saxony-Anhalt in the east and North-Rhine Westphalia in the west will get up to 40 billion euros in compensation from Berlin. Affected companies will get 4.35 billion euros.
They include RWE, which according to two government sources will get 2.6 billion euros for shutting down two coal-fired plants, and miner Mibrag, owned by Czech energy group EPH, which will get 1.75 billion euros.
Shares in RWE, Germany's largest operator of coal-fired power plants, rose as much as 3% to 30.3 euros on the news, their highest level since Sept. 25, 2014.
Energy-intensive companies which compete internationally will be eligible for annual subsidies from 2023 to compensate for higher electricity costs caused by the coal exit, government spokesman Stefan Seibert said, without giving details.
Even so, the BDI industry association criticised the agreement, saying companies had hoped for more help to cope with increased energy costs.
Seibert said that Berlin would also pay compensation to employees affected by the coal exit law up to 2043. The exact sum for each worker remains unclear.
Germany already has plans to phase out hard coal power stations, a process that is already well under way. The new package extends that to brown coal, or lignite, of which Germany is the world's largest producer.
Brown coal generates about 19% of the country's electricity, but is considered the most polluting type of coal, partly because its low energy density means more must be burned.
The process will see at least one more coal-fired power station brought online before a complete exit from coal. Utility Uniper's new Datteln 4 coal-fired power plant will be connected to the grid, since the modern unit is cleaner than the first stations to be taken off line.
Elsewhere, the loss of energy caused by the coal exit will be offset by adding natural gas-powered capacity at existing plants, for example at Jaenschwalde in Brandenburg.
($1 = 0.8956 euros) (Additional reporting by Joseph Nasr; writing by Thomas Escritt; editing by Michelle Martin and Jason Neely)
Our Standards: The Thomson Reuters Trust Principles.