* Merkel's CDU comes first in Saxony but far-right AfD gains
* SPD holds off AfD challenge to come first in Brandenburg
* Results avert immediate crisis for Merkel's national coalition (Adds fresh reaction)
By Paul Carrel and Madeline Chambers
BERLIN, Sept 1 (Reuters) - Chancellor Angela Merkel's conservatives and her Social Democrat (SPD) coalition partners held off a surge in far right support in two state elections in eastern Germany on Sunday, averting an immediate crisis for the ruling alliance.
Merkel's Christian Democrats (CDU) remained the largest party in Saxony but saw their vote share drop by 7.4 points from the last election in 2014 to 32%, with the far-right Alternative for Germany (AfD) coming second, preliminary results showed.
The AfD harnessed voter anger over refugees and the planned closure of coal mines in the formerly communist eastern states, casting itself as the heir of the demonstrators who brought about the fall of the Berlin Wall three decades ago.
In Brandenburg, which surrounds Berlin, the left-leaning SPD clung on to first place in a state they have run since German reunification in 1990, winning 27.2% of the vote - ahead of the AfD on 22.8%, preliminary results showed.
The ruling parties' setbacks were not as major as feared and the results alleviate some pressure on the national coalition led by Merkel, who has loomed large on the European stage since 2005, and could reassure a European Union unnerved by Brexit.
"The results are a reminder of how little CDU and SPD would stand to gain from new elections right now. That might help stabilise Merkel's position, at least for now," said Carsten Nickel, managing director at Teneo, a consultancy.
Much depends on the SPD, which rules with the radical Left party in Brandenburg. The party sank into turmoil after its worst performance in European elections in May, is polling close to record lows and is still searching for a leader.
Many SPD rank-and-file members want to quit a ruling national alliance that has supported Merkel for 10 of her 14 years in power and rebuild in opposition.
Thorsten Schaefer-Guembel, one of the SPD's caretaker leaders, said the coalition was working constructively.
"There is no question there are differences on substance ... but it is clear that this coalition will carry on," he told ZDF television, adding the parties were focusing on issues such as an ambitious climate protection package.
CDU and SPD leaders were relieved at holding off the AfD.
"We have done it. This is a message that goes out from Saxony. The friendly Saxony has won," Michael Kretschmer, CDU state premier of Saxony, told supporters to loud applause. "This is a really good day for our state."
Some members of the CDU, currently in coalition with the SPD in Saxony, have flirted with the idea of cooperating with the AfD, but Kretschmer, and the federal party, have ruled this out.
The next few months will be crucial if the already rocky national coalition is to survive until a federal election due in 2021, with the eastern votes, including a third in Thuringia in October, and the direction of policy both critical.
The parties are due to review the coalition, weakened by rows over migrant policy, tax and pensions, by the year's end.
"Now we need to deliver in the autumn," said Ralph Brinkhaus, leader of the CDU's group in the national parliament.
Voters went to the polls in Brandenburg and Saxony against the backdrop of a growing risk of recession in Germany - a threat that is raising tensions between the CDU and SPD as they argue over whether to shift to a more expansive fiscal policy.
Social Democrats, who control the finance ministry, want to abandon the government's so-called "black zero" balanced budget policy and raise investment but Merkel's conservatives say it is an "indispensable principle" for them.
A coalition collapse could trigger a snap election or result in a minority government - unappealing options for stability-loving Germans. National polls put the conservatives first ahead of the Greens, with the SPD trailing neck and neck with the AfD.
Heavy losses in state votes last year led Merkel, brought up in East Germany, to quit as CDU leader and announce this would be her last term as chancellor.
Her successor as party leader, Annegret Kramp-Karrenbauer, has made several gaffes since taking over and her status as Merkel's heir apparent is looking increasingly fragile. (Additional reporting by Tassilo Hummel and Thomas Seythal and Joseph Nasr; Writing by Paul Carrel; Editing by Alison Williams and Mark Potter)