Germany’s parliament has elected Angela Merkel for her fourth term as chancellor, putting an end to nearly six months of political drift in Europe’s biggest economy.

Politicians voted 364-315 on Wednesday to re-elect Dr Merkel, who ran unopposed. There were nine abstentions.

The coalition of Dr Merkel’s conservative Christian Democratic Union, its Bavaria-only sister party the Christian Social Union and the centre-left Social Democrats has 399 seats.

The same parties have governed for the past four years but putting together the new coalition has proved difficult.

Wednesday’s parliamentary vote comes 171 days - nearly double the previous record - after September’s election, in which they all lost significant ground.

The Social Democrats initially planned to go into opposition.

Dr Merkel will head a much-changed new cabinet, with the governing parties - which are traditional rivals - keen to send signals of renewal. There are new faces in the most important posts, the finance, foreign, economy and interior ministries.

Dr Merkel was able to take office only after two-thirds of the Social Democrats’ members approved in a ballot the coalition deal clinched last month. At least 35 coalition politicians did not support her on Wednesday, though that was in line with results at the beginning of her two previous “grand coalitions” of Germany’s biggest parties.

German Chancellor Angela Merkel receives flowers from the Christian Democratic parliamentary group leader Volker Kauder after she was elected for a fourth term in Berlin. Photograph: Michael Sohn/AP

She will have to hold together what is potentially her most fragile coalition yet in what is widely expected to be her last term, while also addressing challenges such as a potential Europe-US trade war and seeking agreement with France and others on the future of a fractious European Union.

Thorsten Faas, a political science professor at Berlin’s Free University, said the coalition is likely to last until 2021 as scheduled and noted that the governing parties have demonstrated that they can work together.

“A firm foundation, and I think this government has one, is important to be able to work in uncertain times,” Mr Faas told ZDF television. “So I think there is some reason for optimism.” - AP