The party of German Chancellor Angela Merkel has suffered defeats in two of three states holding regional elections, exit polls suggest.
They indicate the Christian Democrats lost support in Baden-Wuerttemberg and Rhineland Palatinate, but remain the largest party in Saxony-Anhalt.
The anti-migrant AfD achieved gains in all three states, exit polls indicate.
The elections were seen as a test of support for Mrs Merkel’s policy of accommodating refugees.
More than a million migrants and refugees entered Germany in 2015.
“We are seeing above all in these elections that voters are turning away in large numbers from the big established parties and voting for our party,” AfD leader Frauke Petry said.
They “expect us finally to be the opposition that there hasn’t been in the German parliament and some state parliaments,” she added.
There were uncomfortable results both for Merkel’s conservative Christian Democratic Union (CDU) and their partners in the national government, the centre-left Social Democrats. Mrs Merkel’s party kept its status as strongest party in Saxony-Anhalt. It had hoped to beat left-leaning Green governor Winfried Kretschmann in Baden-Wuerttemberg, a traditional stronghold that the CDU ran for decades until 2011. It also hoped to oust Social Democrat governor Malu Dreyer from the governor’s office in Rhineland-Palatinate.
However, projections last night showed the CDU challengers finishing up to 5 percentage points behind the popular incumbents in both states and dropping by more than ten points to its worst-ever result in Baden-Wuerttemberg, with some 27 per cent.
The Social Democrats, meanwhile, suffered large losses in both Baden-Wuerttemberg and Saxony-Anhalt, where they were the junior partners in the outgoing governments.
Other parties will not share power with AfD, but its presence will complicate their coalition-building efforts. In all three states, the results were set to leave the outgoing coalition governments without a majority – forcing regional leaders into what could be time-consuming negotiations with new, unusual partners.