German Chancellor Angela Merkel won a fourth term in office today but Europe's most powerful leader will have to govern with a far less stable coalition in a fractured parliament after her conservatives haemorrhaged support to a surging far right.

Two years after Ms Merkel left German borders open to more than a million migrants, the anti-immigration Alternative for Germany (AfD) stunned the establishment by becoming the first far-right party to enter parliament in more than half a century.

The AfD won 13% of the vote - more than expected and one of many shocks on a night of drama that saw Ms Merkel's Christian Democrats (CDU)  get their worst result since 1949, and her main Social Democrat (SPD) rivals their worst since 1933.

Describing the far right's success as a test for Germans, Ms Merkel insisted she had a mandate to govern - a formidable challenge as she has little choice but to cobble together a three-way coalition with a pro-business group and the Greens.

"Of course we had hoped for a slightly better result," a humbled Ms Merkel said after her conservative bloc slumped to 32.9% of the vote - down from 41.5% at the last election in 2013.

But she added: "We are the strongest party, we have the mandate to build the next government - and there cannot be a coalition government built against us."

The euro slipped around 0.4% in early Asian trading as it became clear the results would make forming a coalition tricky for Ms Merkel.

In France, far-right leader Marine Le Pen congratulated the AfD, tweeting: "Bravo to our AfD allies for this historic showing!"

A large group of protesters gathered outside the AfD's post-election party and police said they made several arrests.

The European Jewish Congress expressed alarm at the AfD's success, adding: "We trust that centrist parties in the Bundestag will ensure that the AfD has no representation in the coming governing coalition."

The AfD says immigration threatens German culture, but denies that it is racist: "We will neither tolerate xenophobia or racist positions. But we simply don't have them either," AfD co-leader Joerg Meuthen said.

Leading AfD candidate Alexander Gauland vowed his party would "hunt" the new government, whatever its make-up, adding: "We'll get our country and our people back."

Social Democrats to refuse new coalition

Coalition building could take months as Ms Merkel's only straightforward path to a majority in parliament would be a three-way tie-up with the liberal Free Democrats (FDP) and the Greens - an arrangement untested at national level.

The Social Democrats, who have served with Ms Merkel's conservatives as junior partners in a "grand coalition" for the past four years, won just 20.6% of the vote, as nearly half of voters repudiated the two parties that have dominated Germany since World War Two.

SPD leader Martin Schulz said the party would refuse to rejoin a coalition and instead take up its position as the main opposition. The Social Democrats appear to have been hurt badly by being in government, making it difficult to distinguish themselves from Ms Merkel's conservatives.

After shock election results last year, from Britain's vote to leave the EU to the election of US President Donald Trump, leaders of Europe's establishment have looked to Ms Merkel to rally the liberal Western order.

A pastor's daughter who grew up in Communist East Germany, she has acted as an anchor of stability in Europe and beyond. Now, she faces an unstable situation at home as she must form a coalition, an arduous process that could take months.

Today's election, fought against the tense backdrop of surging support for far left and far right parties across Europe, delivered a fractured German parliament with six party groups, up from four previously.

Josef Joffe, publisher-editor of Germany weekly Die Zeit, said the vote marked a "tectonic shift in German politics" and that the three-way coalition Ms Merkel looks likely to try to forge will be "highly unstable".