Mark Rutte | Dan Kitwood/Getty Images Dutch PM Rutte fends off far right but loses seats Geert Wilders’ anti-Islam party in race for second but fails to make big gains.

Dutch Prime Minister Mark Rutte's center-right party beat off a challenge from far-right firebrand Geert Wilders on Wednesday to come first in a parliamentary election despite losing seats, a projection based on partial results showed.

Rutte's People’s Party for Freedom and Democracy (VVD) was projected to win 32 seats, nine fewer than at the last election in 2012. Wilders' anti-Islam Party for Freedom (PVV) was in a race for second place with two other parties. He was predicted to end up with 19 seats, up four on last time.

The other contenders for second place, the Christian Democrats and the liberal D66 party, both made gains. They were projected to end up with 20 and 18 seats respectively, according to a projection from Dutch news agency ANP, with around 28 percent of votes counted.

The Labor Party (PvdA), Rutte's junior coalition partner, faced the biggest electoral loss in its history. It was forecast to win just 10 seats — down from 38 last time. The GreenLeft party posted a spectacular advance, going from four seats to 14 in the 150-member lower house of parliament.

The vote was widely seen as the first major electoral test of right-wing populism since Britain’s Brexit referendum and U.S. President Donald Trump’s election victory last year. It is also the first major European election in a year that will also see voters in France choose a president and Germany elect a new parliament.

“Our message to the Netherlands worked. We want to continue keeping the country safe and stable in the coming years,” Rutte told supporters at a post-election party in The Hague. "We're hearing the message from all across Europe: the Netherlands stopped the wrong sort of populism.”

Wilders told reporters in parliament that his party was "one of the winners of this vote."

"That’s a result to be proud of,” he said. “We will continue our fight. I think our influence on the campaign and election programs has been significant.”

He also tweeted that "Rutte is not rid of me yet!"

However, his gains fell far short of the progress he had hoped to make. Until recently, opinion polls had been predicting a close race between Wilders' party and Rutte's VVD for first place.

As Rutte intimated, result prompted sighs of relief from European governments. "Large majority of Dutch voters have rejected anti European populists. That's good news," the German Foreign Ministry declared on Twitter. "We need you for a strong #Europe!"

Italian Prime Minister Paolo Gentiloni, preparing to host a 60th anniversary EU summit in Rome later this month, said "the anti-EU right lost the elections in the Netherlands. Now for common engagement to change and relaunch the Union."

German Social Democrat leader Martin Schulz, who is challenging Angela Merkel for the chancellorship, tweeted in both Dutch and German: "I'm relieved. But we must keep fighting for an open and free Europe!"

Populist notes

Rutte last week called upon voters to “stop the domino-effect” of populism. However, the prime minister also sounded some populist notes in his own campaign. In an advert published in Dutch newspapers, he said people should leave the Netherlands if they rejected the country’s values.

The final days of the Dutch campaign were dominated by a bitter dispute between Rutte’s government and Turkey, after Dutch authorities prevented Turkish ministers from holding rallies in support of President Recep Tayyip Erdoğan’s planned constitutional changes.

Rutte will now have to form a new coalition government, a task that could take some time. The next Dutch government looks certain to be made up of four parties, a higher number than ever before. Two permutations looked possible — both led by Rutte's VVD and including the Christian Democrats and the D66 liberals, with either GreenLeft or Labor completing the line-up.

Jeroen Dijsselbloem, Labor finance minister in the outgoing government, described the result for his party as "very disappointing." But the vast majority of voters rejected the extreme populists. Which gives hope for the future," he tweeted.

Turnout in the election was 82 percent, higher than the 74.6 percent in the last parliamentary vote five years ago.

According to the projection, two new parties will enter parliament — the pro-immigrant DENK, with three seats, and the far-right Forum for Democracy with two.