German Chancellor Olaf Scholz's Social Democrats narrowly beat the far-right AfD in a state election Sunday in the formerly communist east, initial projections by public broadcasters said.
Scholz's centre-left SPD won around 31 percent against the anti-immigration, pro-Russian Alternative for Germany, which scored about 29 percent according to the projections.
The result in the state of Brandenburg offers a rare moment of respite for Scholz's embattled coalition government, which has sunk in opinion polls a year ahead of national elections.
The election in Brandenburg has been closely watched because Scholz's SPD has ruled there ever since Germany's 1990 reunification. The chancellor's own electoral district is in the state capital Potsdam, outside Berlin.
The AfD, which rails against asylum-seekers, multiculturalism, Islam and Scholz's government, had hoped to replicate its recent electoral success in the east.
Three weeks ago, it stunned the political establishment by winning its first-ever parliamentary vote -- in the eastern state of Thuringia -- and coming a close second in neighbouring Saxony.
Despite its ballot box success, the AfD is unlikely to take power in any state since all other mainstream parties have so far ruled out entering into a governing alliance with the party.
Brandenburg's popular SPD state premier Dietmar Woidke had kept his distance during the campaign from party colleague Scholz.
In office for more than a decade, Woidke had also thrown down a challenge to voters, by telling them he would quit if the AfD won.
The AfD, which had vowed "to send Woidke into retirement", nonetheless hailed its strong showing. Party co-leader Tino Chrupalla said it had "taken gold once and silver twice" in three elections in the east this month.
A visibly relieved Woidke basked in applause by party faithful, celebrating the close win in a race where just weeks ago his party had trailed the AfD in the opinion polls.
"Our goal from the beginning," he said, was to prevent Brandenburg from being branded with a "great, brown stamp", the colour associated with fascism.
Another AfD co-leader, Alice Weidel, meanwhile declared that overall "we are the strongest force in the east", a region that still lags western Germany in jobs and wealth.
"It's an important stage, as you'll see in the federal elections."
The decade-old AfD, originally a eurosceptic party, has long stoked public fears about irregular migration, especially after a string of recent attacks with suspected Islamist motives.
Germany was shocked by a knife rampage in which three people were killed and eight wounded in Solingen last month. Police arrested a Syrian asylum-seeker who allegedly claimed allegiance to the Islamic State group and had evaded a deportation order.
The AfD's populist rhetoric has heaped political pressure on Scholz and his governing allies, the Greens and the liberal Free Democrats. Both parties scored in the low single digits in Sunday's state election.
Infighting in the government has seen Scholz's approval ratings plummet while his defence minister, fellow Social Democrat Boris Pistorius, often tops surveys as Germany's most popular politician.
In the long run-up to national elections in September 2025, the opposition conservatives of the CDU-CSU alliance last week selected their party leader Friedrich Merz as their top candidate.
But the CDU also took a beating in Brandenburg, winning around 11 percent.
Around 2.1 million people aged over 16 were eligible to vote in Brandenburg.
The state includes wealthy towns such as Potsdam as well as thinly populated rural areas and industrial zones, one of which houses a Tesla plant.
A recent survey in Brandenburg found that immigration was the top concern for many voters.
This year has also seen the emergence of a second populist party, the left-wing Sahra Wagenknecht Alliance (BSW), which won around 12 percent in Brandenburg.
Hailing from former East Germany, Wagenknecht is a veteran opposition politician and frequent TV talk show guest who quit the hard-left Die Linke party to form her own movement.
After scoring well in three eastern state elections, Wagenknecht's party could gain a potential kingmaker role, complicating the task for the other parties who oppose her pro-Russia and anti-NATO stance.