German Chancellor Angela Merkel's party has suffered its worst-ever result in regional elections in the city state of Hamburg, preliminary results say.
The conservative CDU is suffering a leadership crisis after party leader Annegret Kramp-Karrenbauer announced her resignation earlier this month.
The Greens made big gains, while the centre-left SPD is set to remain the largest party.
The far-right AfD lost ground but may just qualify for seats.
The party is currently represented in all 16 German state legislatures and in some parts of the country polls in double digits.
The vote comes days after a racist gunman killed nine people in shisha bars in the western city of Hanau.
'Bitter day' for CDU
The result, if confirmed by final vote figures, will most likely lead to a continuation of the red-green coalition in the left-leaning northern port city.
The Christian Democrats (CDU) have slipped into third place with little more than 11%.
Party general secretary Paul Ziemiak said it was a "bitter day", and acknowledged that Ms Kramp-Karrenbauer's resignation announcement following a scandal in the eastern state of Thuringia had damaged the party.
The CDU there caused consternation by voting with the AfD to elect a regional leader, a move Ms Merkel described as "unforgiveable" and against the CDU's values.
The AfD has grown in popularity in recent years but has been condemned for its extreme views on immigration, freedom of speech and the press.
Meanwhile Greens national co-leader Robert Habeck told German TV the party's performance was a great success.
The preliminary results gave them 24.1%, almost twice as many votes as five years ago.
"We have a very challenging situation for democracy in Germany, and the CDU is tied up in its own problems... It will be up to us to give the land direction and trust," Mr Habeck said.
The party may have benefited from the presence of climate activist Greta Thunberg, who joined thousands of people in a demonstration in the city on Friday.
The Social Democrats (SPD) - Mrs Merkel's coalition partner at national level - received 39.1%, down about six percentage points from the 2015 election but enough for incumbent Mayor Peter Tschentscher to hold onto power.