Germany has agreed to end its reliance on polluting coal power stations by 2038, in a long-awaited decision that will have major ramifications for Europe’s attempts to meet its Paris climate change targets.

The country is the last major bastion of coal-burning in north-western Europe and the dirtiest of fossil fuels still provides nearly 40% of Germany’s power, compared with 5% in the UK, which plans to phase the fuel out entirely by 2025.

After overnight talks, the German coal exit commission of 28 members from industry, politicians and NGOs, which has worked since last summer to thrash out a timetable for ditching coal power, agreed an end date of 2038. A review in 2032 will decide if the deadline can be brought forward to 2035.

Hans Joachim Schellnhuber, a member of the commission and an adviser to the German chancellor, Angela Merkel, said: “This is an important step on the road to the post-fossil age – a step that also opens up new perspectives for the affected regions through innovation-driven structural change.” But he said it had been difficult to reach a consensus on how quickly to phase out coal.

Stefanie Langkamp, a coal expert at the Climate Alliance Germany network, cautiously welcomed the decision.

She said: “It is good that the long-overdue entry into the coal phaseout is now beginning and that new perspectives are being developed in the regions. Measured against the climate crisis, however, the coal phaseout should have been much more ambitious.”

However, RWE, which runs many of the country’s coal plants, said the 2038 date was “far too early” for the company and said the 2032 review would be a chance to extend the final end date. In a statement the firm said the proposals: “would have far-reaching consequences for the German energy sector and in particular for RWE.”

Rolf Martin Schmitz, RWE’s chief executive, warned the plan would have “serious consequences” for the company’s lignite, or brown coal, business.

Coal union members greeted a meeting of the coal exit commission in Berlin on Friday with a demonstration urging against a hasty phaseout.

Meanwhile, thousands of schoolchildren took part in a protest on the same day in the German capital, calling for the end of coal to tackle global warming.

The final 336-page document agreed by the coal commission, seen by the Guardian, shows Germany plans to reduce its 42.6GW of coal power capacity to about 30GW by 2022, falling to around 17GW by 2030. The deal will be formally published next Friday.

Greenpeace has called for an end date of 2030, but other environmental groups in the country supported a 2035 cut-off. Almost three quarters of Germans believe a quick exit from coal is important, according to a poll of 1,285 people by the broadcaster ZDF.

Dave Jones, a power analyst at the London and Brussels-based thinktank Sandbag, said: “2035 is really the ambitious solution. The bigger question is about how quickly it happens [for example, interim goals].”

The commission said that gas would become Germany’s backup power of choice, rather than coal, which would make it more similar to the UK energy system.

Merkel, speaking in Davos last week, said that, as the country ditches coal and closes its last nuclear plants in 2022, “we will need more natural gas, and energy needs to be affordable.” Her government has a goal of increasing the share of renewables in electricity supply from 38% today to 65% in 2030.

One of the most contentious issues has been the cost of compensating energy firms for shutting coal plants before the end of their lifetime.

About €40bn will be awarded under the commission’s plans; the industry had hoped for €60bn. The German energy secretary, Thomas Bareiß, has said the move away from coal was necessary but would be a “very expensive transition”.