BERLIN- Germany's cabinet backed a draft law on Wednesday to funnel billions of euros in financial support to regions affected by plans to phase out coal, days before two of them hold crunch state elections.

The draft law envisages state aid totalling 40 billion euros ($45 billion) spread over the next 20 years, mostly to four regions affected by the plans to phase out coal by 2038 - part of Germany's transition to renewable energy, known as the 'Energiewende'.

Two of the states to benefit are Brandenburg and Saxony, which both hold regional elections on Sunday at which Chancellor Angela Merkel's conservatives and her Social Democrat (SPD) partners are expected to bleed support to the far-right.

A surge in support for the far-right Alternative for Germany (AfD) in the two former communist eastern states threatens to wreck Merkel's unwieldy right-left coalition government. 

Polls show the AfD is running neck and neck with the SPD in Brandenburg, a state the Social Democrats have run since German reunification in 1990, and is a close second to Merkel's Christian Democrats (CDU) in Saxony.

The AfD has sought to attract voters in the poorer East by prioritising coal jobs above the environment. 

Economy Minister Peter Altmaier, a close Merkel ally, said the exit from coal was needed to bring the opportunity for the affected regions to reinvent themselves while also helping to protect the climate.

"With today's law, we are paving the way for aid to flow quickly and for a successful structural change to take place," he said in a statement.

The other regions to profit most from the aid are the eastern state of Saxony-Anhalt and North Rhine-Westphalia in western Germany.

 

($1 = 0.8973 euros)

(Reporting by Markus Wacket and Paul Carrel Editing by Gareth Jones) ((paul.carrel@thomsonreuters.com;; +49 30 2888 5216; Reuters Messaging: Reuters Messaging: paul.carrel.thomsonreuters.com@reuters.net))