Image copyright Getty Images Image caption The Greens are set to more than double their vote in Hamburg as they continue a nationwide surge
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.
- Merkel loses control of own succession
- Why far right is blamed for Hanau shooting
'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.
- How far right caused earthquake in German politics
- Just how far to the right is AfD?
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. Image copyright AFP Image caption Social Democrat Mayor Peter Tschentscher seems likely to hold onto power
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.
Watch Brazilian carnivals live, discuss the next world conflict in the video chat or just enjoy fresh videos with funny cat talking - with Ulive.news you are at the center of any event! Ask a streamer to show what is happening from a different angle, to ask a question to eyewitnesses or to pay attention to an important detail. We will translate your message into 64 languages so that you can easily understand each other.