The anti-refugee party, Alternative für Deutschland (AfD), has shaken up Germany’s political landscape with dramatic gains at regional elections, entering state parliament for the first time in three regions off the back of rising anger with Angela Merkel’s asylum policy.

But, in a sign of the increasingly polarised nature of Germany’s political debate, pro-refugee candidates also achieved two resounding victories in the elections – the first to take place in Germany since the chancellor embarked on her flagship open-doors approach to the migration crisis.

Merkel’s Christian Democrat party suffered painful defeats to more left-leaning parties in two out of three states, including Baden-Württemberg, a region dominated by the CDU since the end of the second world war. The news weekly Der Spiegel described the result as a “black Sunday” for the conservatives. The CDU also failed to oust the incumbent Social Democrats in Rhineland-Palatinate.

But it was the breakthrough of the AfD – a party that did not exist a little more than three years ago and last year was on the verge of collapse – that was arguably most striking. In Saxony-Anhalt in the former east Germany, the party with links to the far-right Pegida movement had gained 24.4%, according to initial exit polls, thus becoming the second-biggest party behind the CDU. In both Rhineland-Palatinate and Baden-Württemberg, it appeared to have gained 12% and 15%.

Angela Merkel: enigmatic leader of a divided land | profile Read more

Germany’s rightwing upstarts appeared to have benefited from an increased voter turnout across the country. In all three states, the AfD gained most of its votes from people who had not voted before, rather than disillusioned CDU voters. In Saxony-Anhalt, as many as 40% of AfD voters were previously non-voters, while 56% of AfD voters in the state said they had opted for the party because of the refugee crisis, according to one poll.

The AfD was founded in 2013 by a group of economists and journalists calling for the abolition of the euro. After the resignation last year of its founder, Bernd Lucke, the party has focused on campaigning against the government’s refugee policy, calling for the reintroduction of border checks.

The AfD’s election manifesto also calls for a referendum on TTIP and the immediate suspension of sanctions towards Russia. In an interview last week, Merkel described the populist party as a “temporary phenomenon” – with the party now entrenched in state parliament this seems less likely.

Andre Poggenburg, the AfD’s lead candidate in Saxony-Anhalt, said: “We have achieved something very important: we have mobilised many non-voters to take part in the election, something the established parties have failed to do.” The party’s deputy leader, Alexander Gauland, told supporters at a rally on Sunday night that his party would “chase the old parties to hell”.

The elections came after a dramatic seven months that have seen the German public become increasingly polarised over their chancellor’s open-border stance, with well over 1.1 million refugees entering the country in the past year and the euphoric welcome given to many refugees last summer at Munich train station being replaced by anger, especially when, on New Year’s Eve in Cologne, hundreds of women were reported to have been sexually harassed and raped by men of largely north African and Arabic background.

If the AfD’s strong showing reflected deep hostility to Merkel’s plan, however, other results told a different story. The CDU’s poor showings will not necessarily be seen as a substantial blow to the chancellor’s leadership partly because, during the campaign, CDU candidates in all three states had distanced themselves to varying degrees from their leader’s strategy for the refugee crisis. The politician who won in Baden-Württemberg, Green state premier Winfried Kretschmann, had passionately defended the German chancellor’s open-borders stance, stating in one day that he was “praying every day” for her wellbeing.

With a centrist, pro-business party programme that defied orthodox ideas of what an environmental party should stand for, the Green party in Germany’s south-west managed to come top with 30.5%. Remarkably, 30% of voters who had switched from Christian Democrat to Green in the state said they had done so because of the refugee debate.

Frauke Petry: smiling face of Germany’s resurgent right Read more

“In Baden-Württemberg we have written history”, Kretschmann told reporters after the first exit polls.

In Rhineland-Palatinate, the incumbent Social Democrat state premier defeated Christian Democrat, Julia Klöckner, who had been seen as a potential successor to Merkel. Klockner had seemingly been cruising towards a victory in the state but appeared to fall out of favour after calling for an alternative plan to her party leader’s management of the refugee crisis.

According to Frankfurter Allgemeine Sonntagszeitung newspaper, the chances of the chancellor’s authority being called into question by bad results for her party were “unlikely, but not out of the question”. While Merkel will face a renewed debate inside her party over the electoral cost of her refugee policy, she is also now able to show that questioning her course comes at a political cost. “Things won’t get really dangerous for Merkel”, Spiegel wrote.

Merkel’s personality ratings have risen again after hitting a low at the start of the year. In a Forsa poll published last week, the chancellor enjoyed an approval rate of 50%, her highest this year.

In an election described as “pure federalism” by one TV commentator, many parties who celebrated victories in one state suffered drubbings in others. In particular the Social Democratic party, which governs the country in a coalition with Merkel’s CDU, will be nursing its wounds after its share of the vote almost halved in Saxony-Anhalt and Baden-Württemberg, and it came fourth behind the AfD in both states.

With five parties entering state parliaments in all three regions, politicians will spend the coming weeks forging complicated – and most likely unusual – coalitions. In Saxony-Anhalt, the SPD’s collapse means that the Christian Democrats lack a strong enough coalition partner and may be required to form a CDU-SPD-Green coalition, colloquially known as an “Afghanistan coalition” after the traditional colours of the German parties.

• This article was amended on 14 March 2016. An earlier version said the SPD lost about 10% of its voters in Saxony-Anhalt and Baden-Württemberg; its share of the the vote dropped by about 10 percentage points. A reference to Baden-Württemberg being in Germany’s northwest was corrected to place it in the southwest.