Chancellor Friedrich Merz ruled out working with the Alternative for Germany (AfD) on Monday after the far-right party surged into first place in state elections in Saxony-Anhalt, but he conceded the result had shaken his party “to its very foundations”.The AfD is appealing to lawmakers from Merz’s conservatives to support its bid to rule the eastern state, in what would be the first time a far-right party takes power at state level in post-war Germany.The anti-immigrant, pro-Russia AfD won nearly 44 per cent of the vote, an outcome that underlined the deep unpopularity of Merz’s ruling coalition ‌and also triggered alarm among Germany’s neighbours, France and Poland, and elsewhere.However, the party – which wants to deport immigrants, halt support for Ukraine and restore ties with Moscow – fell short of an absolute majority in the state legislature, winning 39 of the 83 seats, and hopes to poach individual conservative lawmakers.The election result could test the long-standing refusal of Germany’s mainstream parties, including Merz’s Christian Democrats (CDU), to work with the AfD, a policy known as the “firewall”. The AfD says this is undemocratic.“This shakes our party to its very foundations,” Merz said, according to the Bild newspaper. “We are all deeply shocked,” he added later at a press conference, describing the result as his party’s worst election result in decades.