Angela Merkel's ruling CDU party has been beaten into third place by an anti-immigrant and anti-Islam party in elections in a north-eastern German state.
The Alternative fuer Deutschland (AfD) party took just under 21% of the vote behind the centre-left SPD's 30%.
The German chancellor's CDU was backed by only 19% of voters, its worst ever result in the state.
The vote was seen as a key test before German parliamentary elections in 2017.
Before the vote in Mecklenburg-West Pomerania, in the former East Germany, all of Germany's other parties ruled out forming a governing coalition with the AfD. But the party, formed only three years ago, is already represented in nine of Germany's 16 state parliaments.
One leading CDU politician called the result catastrophic, while another, Wolfgang Bosbach, said the arrival of hundreds of thousands of migrants without documents had "put the wind in the AfD's sails".
Analysis: By Jenny Hill, BBC Berlin correspondent
This is humiliating for Angela Merkel - not least because this was on home turf. Mrs Merkel's constituency is in Mecklenburg-West Pomerania.
This election - which was seen as a significant test ahead of next year's general election - was all about her refugee policy. For a year she's insisted 'Wir schaffen es' (we can do it) but German voters aren't convinced.
Alternative fuer Deutschland's anti immigrant and increasingly strident anti-Islam message has a powerful appeal to people concerned about integration and worried about domestic security.
It doesn't look good for Mrs Merkel. Her approval ratings are at a five-year low. But don't be tempted to write her off just yet - she has a habit of bouncing back and there is no serious contender waiting in the wings to replace her.
Under her leadership, Germany has been taking in large numbers of refugees and migrants - 1.1 million last year - and anti-immigrant feeling has increased.
The AfD, initially an anti-euro party, has enjoyed a rapid rise as the party of choice for voters dismayed by Mrs Merkel's policy.
But its political power is limited and critics accuse it of engaging in xenophobic scaremongering.
The CDU has been the junior coalition partner in Mecklenburg-West Pomerania since 2006 and is likely to remain in the governing coalition. However, its 19% in the election is its worst ever result in the state, German broadcasters said.
"The strong performance of AfD is bitter for many, for everyone in our party," said CDU secretary general Peter Tauber. "A sizeable number of people wanted to voice their displeasure and to protest. And we saw that particularly in discussions about refugees."
BBC Berlin correspondent Damien McGuinness says that following her political embarrassment, Mrs Merkel will now come under greater pressure to change her welcoming position on refugees.
Addressing supporters, local AfD leader Leif-Erik Holm said: "Perhaps this is the beginning of the end of Angela Merkel's chancellorship today."
Mrs Merkel, who is in China for the G20 summit, told Bild newspaper on Saturday: "We did not reduce benefits for anyone in Germany as a result of the aid for refugees. In fact, we actually saw social improvements in some areas.
"We took nothing away from people here. We are still achieving our big goal of maintaining and improving the quality of life in Germany."
More on AfD
- Founded in 2013 by Bernd Lucke, Alexander Gauland and Konrad Adam to oppose German-backed bailouts for poorer southern European countries
- Mr Lucke, seen as a moderate, wanted Germany out of the euro but his colleagues were unhappy that he wanted to focus exclusively on euro-related issues
- He quit the party in early July 2015, arguing it was becoming increasingly xenophobic
- Right-winger Frauke Petry replaced him as party leader
- It became the first anti-euro party to win seats in a German regional parliament, receiving almost 10% of the vote in the eastern German state of Saxony in 2014, and went on to win seats in other states' parliaments
- The party had seven MEPs elected in the 2014 European elections (including Mr Lucke), but only two remain party members
- The party adopted an anti-Islam policy in May 2016
- In one southern state, the party split after a representative suggested the Holocaust was given too much attention.
German newspapers see pressure rising
"How many more electoral disasters can Merkel take?" wonders tabloid Bild, and predicts that temporarily pacified opposition to Mrs Merkel's line inside her conservative bloc could erupt with full force.
In fact, a senior member of the powerful Bavarian sister party of Ms Merkel's Christian Democrats, Markus Soeder, has already called for a "change of course" in remarks to Bild.
But a commentary in news magazine Der Spiegel believes that while the election is a "debacle" for Ms Merkel, her job is not on the line quite yet.
Some also think it's not all just about Mrs Merkel. A commentary in Frankfurter Allgemeine Zeitung argues that voters are angry at "(almost) all" mainstream parties, and not just the Christian Democrats, mainly over globalisation and "compromise-based politics".