(CNN)Angela Merkel was sworn in as Chancellor of Germany after lawmakers voted to re-elect her as leader in a close vote on Wednesday morning.
Angela Merkel sworn in for fourth term as German Chancellor
She will now begin a historic fourth term as Chancellor.
The vote in parliament ended almost six months of political turmoil after a federal election saw millions of voters desert the two mainstream parties -- Merkel's Christian Democratic Union and the Social Democratic Party (SPD) -- turning instead to parties on the left and right.
At 171 days, it is by far the longest period in modern German history between a federal election and the election of a Chancellor.
In a secret ballot, 364 of the Bundestag's 709 members voted in favor of Merkel -- nine more than the 50% required. Thirty-five MPs from the parties governing under Merkel did not vote to re-elect her.
Speaking on Monday in expectation of her re-election, Merkel said: "I think everyone has the feeling it's time to finally start working. A new departure for Europe, a new dynamic for Germany, new cohesion for our country -- that's what we have before us... So there is a lot of work ahead."
Merkel's victory marks the final stepping stone on the path to Germany's new government -- a renewal of the so-called grand coalition ("GroKo") between the Chancellor's CDU/Christian Social Union alliance and the SPD.
The former leader of the SPD, Martin Schulz, had initially ruled out a new GroKo, pledging to take his party into opposition, but was forced to change his stance after coalition talks between the CDU, Green Party and liberal Free Democratic Party collapsed in November, raising the possibility of new elections.
After weeks of negotiations, a coalition treaty was produced and later approved by SPD members who voted via postal ballot. But many SPD members and politicians remain unhappy with their party's involvement in the new coalition.
In a speech nominating Merkel as Chancellor on Wednesday morning, President Frank-Walter Steinmeier warned that the new coalition must win back the trust of voters and protect Germany's liberal democracy, alluding to the rise of the far-right Alternative for Germany (AfD) without mentioning the party by name.
"In order to win back lost trust, a simple restoration of old ways will not suffice. This government has to prove itself in new and different ways."
"The liberal democracies of the West are beset with challenges -- from without as well as from within," he said. "Even in parts of Europe elections are being won with isolationism, nationalism and an unwillingness to compromise."