Kim Hjelmgaard

USA TODAY

BERLIN — German Chancellor Angela Merkel's party showed surprising strength Sunday against its main opponent in a state election that also produced gains for an anti-immigration party.

Preliminary results showed Merkel's conservative Christian Democratic Union won 40.7% of the vote in tiny Saarland state, in southwestern Germany. That was up from 35.2% in 2012 and topped the 29.6% won by the Social Democrats led by Martin Schulz.

Alternative for Germany (AfD), an anti-European Union and anti-immigration party, won 6.2% of the vote, enough to gain representation in its 11th state parliament.

There are 16 state parliaments in Germany. AfD is not represented in the country's national parliament. Last year, polls showed support for AfD hit a record-high 16% nationally but it has lost momentum since then.

The unexpectedly strong win for Merkel's party over Shulz's center-left group comes ahead of a September general election that could test Merkel's hopes for a fourth term. AfD is likely to gain a federal parliament seat for the first time in that election.

Earlier this month, anti-Islam, anti-immigration politician Geert Wilders failed to win the most votes in a Dutch election that became a bellwether of populist sentiment in Europe. French voters will test the strength of anti-establishment feeling in a national election in April and May.

Ahead of Sunday's German vote, polls showed a much tighter race as a result of a recent increase in Schulz's popularity. "Everything said about the Schulz train rolling over everything and changing everything didn’t come true," Armin Laschet, a Christian Democrat deputy leader, told broadcaster ZDF on Monday.

Schulz has campaigned on a platform that is viewed as an alternative to the right-wing populism that has swept Europe in recent times. He is a vocal critic of President Trump and strongly backs the European Union. He stepped down as president of the EU's Parliament to run for chancellor.

National polls show Merkel and Schulz in a neck-and-neck race to be Germany's next leader. Their parties are in Germany's current ruling coalition government.

Two more state elections are scheduled for May.

"We have picked up support in the last few weeks, in Saarland too, and we are looking ahead,” Schulz said Monday in comments that struck an optimistic tone.

"We’re in it for the long haul, that message goes to those celebrating today, understandably from their point of view, but (they) should not celebrate too early."

More on Germany's elections:

Germany's Merkel admits migrant policy cost votes

How fake news could put German election at serious risk