Olaf Scholz’s Social Democrats held off the far-right Alternative for Germany (AfD) and look set to cling on to power in the eastern state of Brandenburg, sparing the chancellor and his party another embarrassing electoral setback.

The Social Democratic Party of Germany (SPD), which has ruled the former communist region surrounding Berlin since reunification in 1990, secured a narrow victory in Sunday’s election, with 30.9% of the vote, according to preliminary results, halting a run of woeful performances by the party in state ballots. The anti-immigrant AfD, which is much stronger in eastern Germany than in the west and won in Thuringia this month, came in second, with 29.4%.

That means the SPD’s popular state premier, Dietmar Woidke, is likely to remain in power, which would leave Scholz grateful that his critics don’t have the result in Brandenburg — which is home to his Potsdam constituency — to add to his list of troubles.