Germany’s centre-left parties consolidated their governing majority in state elections in the northern city of Hamburg on Sunday, while support for Angela Merkel’s conservatives dropped to a historic low and the far right crossed the threshold for entering parliament only by the narrowest of margins.

The Social Democratic party (SPD) bucked the national trend by holding on to one of its few remaining strongholds, emerging top with 39% of the vote. The Greens, the SPD’s junior coalition partner, doubled their share to 24.2%.

The crisis in the CDU, which has been in turmoil since the resignation of the party leader, Annegret Kramp-Karrenbauer, earlier this month, was deepened further after the centre-right party came third with only 11.2%, the second worst result at a state-level vote in the party’s history.

The CDU will hold an extraordinary party congress on either 25 April or 9 May to elect a new chair and gain clarity over who will lead the conservatives into the next federal elections, scheduled for 2021.

The far-right Alternative für Deutschland, on the back of strong gains at state elections in the former East Germany last year, performed poorly, only narrowly managing to scrape over the 5% hurdle for entry into parliament.

Because of Hamburg’s complicated election rules, a final result is not expected to be confirmed until Tuesday.

Local factors are likely to have played a bigger role than national events at the voting booth in Germany’s second largest city, one of the wealthiest regions in Europe. Hamburg’s SPD is seen as more centrist and business-friendly than the leftwing leadership at federal level, and the mayor, Peter Tschentscher, had a strong record on building new housing, expanding free day-care and increasing the number of all-day schools to boost his case.

Both the SPD and the Greens can claim to have put into practice the outcome of a 2013 referendum in favour of bringing the city’s utilities grids back into public hands with considerable success.

But as the only state elections scheduled in Germany this year, the outcome of the vote nonetheless has symbolic power.

Coming just days after a racist gunman murdered 10 people in the western city of Hanau and weeks after a scandal over centre-right parties voting with the AfD in the eastern state of Thuringia, the Hamburg vote shows that the far right’s aggressively nationalistic posturing and xenophobic rhetoric does not necessarily have to set the political agenda.

While the total number of votes for the AfD remained relatively stable, the party’s share was pushed down by an increased turnout in support of the centre-left, possibly in protest against the racially motivated attack in Hanau.

For a CDU trying to establish whether the way out of Merkel’s shadow involves sticking to her centrist course or tacking right, its poor showing among urban voters will offer food for thought.

Paul Ziemiak, the general secretary of Merkel’s party, described the result as “historically poor”, adding that his party’s confused course in Thuringia had not helped its case.