ROME — Populists took power in Italy for the first time Friday with the swearing-in of a new government, fusing in a coalition a political movement that delights in pillorying the establishment and a party whose anti-migrant, euro-skeptic politics have seen it soar in popularity.

At an oath-taking ceremony in the presidential palace atop Quirinal Hill, the new premier, political novice Giuseppe Conte, and his 18 Cabinet ministers pledged their loyalty to the Italian republic and to the nation’s post-war constitution in front of President Sergio Mattarella.

Only five days earlier, the leader of the anti-establishment 5-Star Movement, Luigi Di Maio, was inciting followers to press for Mattarella’s impeachment. The president had invoked his constitutional powers to reject the populists’ initial choice for economy minister because he is an advocate of a backup plan to exit from euro-currency membership.

Mattarella’s act scuttled Conte’s first try to assemble a coalition uniting the forces of Di Maio’s 5-Stars and his populist rival Matteo Salvini, leader of the right-wing League, which is based in the affluent north.

The president approved Conte and a rejiggered Cabinet list Thursday after Paolo Savona was moved from the economy slot to that of the ministry of European affairs. On Friday, a beaming Di Maio stood before Mattarella and recited the loyalty oath – he’ll serve as minister of labor and economic development.

The initial failure of Conte to form a government had alarmed financial markets, which feared a quick return to the polls that risked being tantamount to a plebiscite on Italy’s keeping the euro currency.

But the markets were reassured by the formation of a new government, which came three months after elections resulted in a political stalemate with no single party or alliance winning control of Parliament.

On Friday, the 5-Stars clinched their quest for national power, after five years in Parliament as the largest opposition party. Co-founded by comic Beppe Grillo, who rails against an entrenched political “caste,” the movement bills itself as a web-based democratic force, not a traditional political party.

Grillo tweeted euphorically: “If you can dream it, you can do it.”

Conte was a professor of law at the University of Florence, who had offered ahead of the March election to serve as a 5-Star minister. He became a compromise choice for premier when rivals Di Maio and Salvini refused to let each other hold the top post.

Emphasizing their “anti-establishment” claim, 5-Star ministers, who hold seven of the Cabinet posts, took a single taxi van to the Quirinal Palace.

In a Facebook post, Di Maio gushed: “There are a lot of us, and we’re ready to launch a government of change to improve the quality of life for all Italians.”

Next week the government faces mandatory confidence votes in each chamber of Parliament, where the coalition members hold narrow, but viable majorities.

Salvini said he would set straight to work on a campaign pledge to expel many of several hundred thousand asylum-seekers who were rescued at sea from human traffickers over the last few years but are ineligible for asylum.

Public resentment over what was perceived as fellow EU nations’ failure to help ease the financial and logistical burden on Italy in caring for the flood of migrants helped boost the League’s popularity.

“The immigration question is still burning,” Salvini said.

The last-minute compromise appointment of Giovanni Tria as economy minister was aimed at calming EU leaders’ jitters. He is close to the center-right forces loyal to Silvio Berlusconi, the former premier and billionaire media mogul.

Conte himself acknowledged that the populists are a whole new breed that is leaving some wondering what they will be like.

“We’re not Martians, and we’ll prove it,” said the premier.