ROME — Italians registered their dismay with the European political establishment on Sunday, handing a majority of votes in a national election to hard-right and populist forces that ran a campaign fueled by anti-immigrant anger.

The election, the first in five years, was widely seen as a bellwether of the strength of populists on the continent and how far they might advance into the mainstream. The answer was far, very far.

After Chancellor Angela Merkel of Germany and President Emmanuel Macron of France beat back populist and far-right insurgencies in the past year, Europe had seemed to be enjoying a reprieve from the forces threatening its unity and values.

That turned out to be short lived.

In Sunday’s vote, preliminary results showed, the parties that did well all shared varying degrees of skepticism toward the European Union, with laments about Brussels treating Italians like slaves, agitation to abandon the euro and promises to put Italy before Europe.