FILE - In this Feb. 26, 2018 file photo German Chancellor and party chairwoman Angela Merkel smiles at the party convention of the Christian Democratic Union CDU in Berlin. The members of the Social Democratic party voted for a coalition agreement with Merkel's party paving the way for Merkel's fourth term as German Chancellor. (AP Photo/Markus Schreiber, file)

FILE - In this Feb. 26, 2018 file photo German Chancellor and party chairwoman Angela Merkel smiles at the party convention of the Christian Democratic Union CDU in Berlin. The members of the Social Democratic party voted for a coalition agreement with Merkel's party paving the way for Merkel's fourth term as German Chancellor. (AP Photo/Markus Schreiber, file)

BERLIN (AP) — Germany ended months of political uncertainty Sunday when Chancellor Angela Merkel gained the support needed to preserve her governing coalition and secure a fourth term as leader of Europe’s most powerful economy.

The center-left Social Democrats voted overwhelmingly to remain in a coalition with Merkel’s conservative bloc, after difficult and drawn-out negotiations triggered by September’s elections, which saw the rise of a new right-wing force in German politics and raised questions about Merkel’s future.

ADVERTISEMENT

Parliament is expected to meet March 14 to re-elect Merkel as chancellor, ending the longest time Germany has been without a new government after elections in its postwar history.

Merkel has drawn flak from both left and right for maintaining an unabashedly centrist course since taking office in 2005. With the coalition approved, she can now turn her attention to tackling rising anti-immigrant sentiment in Germany while pushing forward efforts to reform the stumbling European Union.

“I congratulate the SPD on this clear result and look forward to continuing to work together for the good of our country,” she said on Twitter.

Merkel’s survival drew cheers from her allies at home and abroad, with French President Emmanuel Macron declaring it “good news for Europe.”

“France and Germany will work together in the coming weeks to develop new initiatives and advance the European project,” Macron said in a statement.

Belgian Prime Minister Charles Michel expressed hope that the end of Germany’s six-month political limbo would allow the EU to step up efforts to deal with such issues as immigration, security and trade.

In a veiled reference to the United States under President Donald Trump, Michel cited the threat of protectionism, the weakening of international cooperation and the issue of climate change as challenges the 28-nation bloc must face.

Merkel, who has proved herself a shrewd international negotiator during more than 12 years in office, faced her greatest challenge at home after deciding to allow over a million asylum-seekers into Germany since 2015. An anti-migrant party came in third in last year’s election, upending Germany’s traditional coalition calculus.

With Merkel’s bloc and the second-place Social Democrats in government, the right-wing Alternative for Germany, or AfD, now represents the biggest opposition party in Parliament, giving it a prominent platform to attack the chancellor.

ADVERTISEMENT

Its leaders have vowed to “hunt” Merkel, though so far AfD’s novice lawmakers have stood out mainly by failing to grasp parliamentary procedures and putting forward motions all other parties reject.

The Social Democrats were initially reluctant to extend their coalition with Merkel but eventually agreed to a deal that gives them control of the foreign, labor and finance ministries — three major portfolios — in return for supporting curbs on immigration.

Conservatives in Merkel’s bloc have demanded the country of about 80 million take in no more than about 200,000 migrants a year. Immigration is expected to be a key issue in this fall’s state election in Bavaria, where Merkel’s allies fear the fallout from her open-door policies.

Some within the Social Democratic Party, particularly on the left, had argued that the party wouldn’t benefit from propping up Merkel for another term. In the end, though, two-thirds of its 464,000 members voted in favor of the coalition deal.

Had the long-time German leader faced a “no” result, she would have been left with only two realistic options: forming a minority government or seeking a new election.

“This was a really important democratic decision for our country,” said acting Social Democrat leader Olaf Scholz, who is in line to become Germany’s next finance minister and Merkel’s deputy. The party will put forward six names for ministerial posts in the coming days.

In a first step at rejuvenating her party, Merkel has already named several up-and-coming figures to replace veteran ministers in the next Cabinet and backed Annegret Kramp-Karrenbauer for a key post at the top of the party in what some commentators say could signal Merkel’s preferred successor.

___

Follow Frank Jordans on Twitter at http://www.twitter.com/wirereporter