German Chancellor Angela Merkel has won a fourth term in office after a general election that has surged an overtly nationalist party to enter parliament for the first time in decades.

Merkel's centre-right Christian Democratic Union party secured 33 percent of the vote on Sunday, down about nine percent compared to the last election in 2013.

Their main rival and current coalition partner, the centre-left Social Democrats led by Martin Schulz, got around 21 percent of the vote - their worst result in post-war Germany.

But the biggest change to Germany's political scene was the emergence of the far-right Alternative for Germany (AfD) party as the country's third biggest political force with 12.6 percent of the vote.

READ MORE: Who are Germany's far-right AfD?

The pro-business Free Democrats (FDP) bounced back into parliament with 10.1 percent of the vote, while the environmental Greens scored 9.2 percent and the leftist Die Linke picked up 8.9 percent.

Addressing supporters at party headquarters, Merkel, who will now have to find new coalition partners, said she hoped for "better results".

"Let's not beat around the bush, of course we would have preferred a better result, that's completely clear," Merkel said after the announcement of the exit polls.

"But let's also not forget that we have just come out of an extraordinarily challenging legislative period," Merkel added.

READ MORE: Anti-AfD protests erupt in Berlin

Al Jazeera's Dominic Kane, reporting from now said the big question now is who Merkel is going to govern with.

"And this a question Merkel did not address in her victory speech," Kane said.

READ MORE: What Germany's refugees think about the elections

Commenting on the AfD's performance, Kane said: "this is not the first time since WWII that an overtly nationalist party has won seats in a form of the German parliament".

He added, however, that "certainly this is the first time that a far-right party has won so many votes, and therefore so many seats proportionately in the parliament."

The far-right, anti-immigrant party was founded just four years ago as an anti-euro force. Its manifesto included a pledge to ban all mosques and criminalise people wearing the veil.

Under Merkel's leadership, Germany opened its doors to about a million asylum seekers at the height of Europe’s refugee crisis in 2015, prompting fierce criticism from the AfD leadership, who say her stance has had an unacceptably high fiscal, social and administrative cost.

Nina Schick, political analyst at consultancy firm Hanbury Strategy said, it is "very important to keep things in perspective" when analysing the AfD's election performance, citing a "huge change" in German society in the wake of the refugee crisis.

"The fact they are on 13 percent, yes it's a kickback, a reaction to what's happened to the German society but the other side of the coin is that a million refugees and asylum seekers came to the country and are being integrated into society and millions of Germans are helping them to learn the German language and try to get jobs," she said.

"So it’s not as bad as some might think given the huge change that Germany faced with the refugee crisis."

Coalition talks

Forming a coalition government is expected to be an arduous process for Merkel that could take months as all potential partners are unsure whether they really want to share power with her.

Schulz ruled out a re-run of Merkel's existing alliance with the SDP after the centre-left party's disappointing results.

"It's perfectly clear that the electorate has directed us to go into opposition," Schulz said.

An alternative coalition for Merkel would be a three-way tie-up with the FDP and the Greens. That is a combination as yet untested at the national level.

Both the FDP and the Greens have played down the prospect of a coalition, but as they have been out of government for four and 12 years respectively, they may be lured into an alliance by the prospect of power.

"It will now be much more challenging for her to build a coalition in the first place because she will have to deal with two different parties, with different cultures," Olaf Boehnke, senior adviser at Rasmussen Global, told Al Jazeera.

"There is very leftish wing in the Greens party, and there is a very conservative, even close to nationalism, wing in the FDP," he added.

Pointing to the big drop in support for Merkel's Christian Democrats, Boehnke argued that the chancellor was both the "winner and the loser" of the election.

"And this also makes here as a coalition partner quite unattractive to her new potential coalition partners because she always manages to ruin them, in a way, as we are now seeing with the SPD," he said.

Merkel campaigned on her record as chancellor for 12 years, emphasising the country's record-low unemployment, strong economic growth, balanced budget and growing international importance.

The election victory sets the 63-year-old on course to match Helmut Kohl’s record as the longest-serving leader in German’s post war history.

Polls opened at 8am (06:00 GMT) and closed at 6pm (16:00 GMT) with turnout slightly lower than four years ago.