ROME -- Italy's president swore in western Europe's first populist government Friday, featuring a mix of anti-establishment and right-wing ministers who have promised an "Italy first" agenda that has alarmed Europe's political establishment. The continent's euroskeptic politicians cheered the birth of the new government coalition of the 5-Star Movement and the right-wing League party.

President Sergio Mattarella, who negotiated through three months of political deadlock to finally find a workable government, presided over the ceremony in the gilded Quirinale Palace.

Milan's stock market rose after a last-minute deal Thursday averted the threat of an early election that could have turned into a referendum on whether Italy should ditch the shared euro currency.

Get Breaking News Delivered to Your Inbox

Eighteen ministers -- five of them women -- took the oath of office, pledging to observe Italy's constitution and work exclusively in the interests of the nation. The ministers feature a mix of 5-Star and League loyalists, and a political neophyte in the form of Premier-designate Giuseppe Conte, who was still teaching his law classes at the university in Florence up until Thursday.

Italy's newly appointed Prime Minister Giuseppe Conte announces the list of his government at the Quirinale presidential palace on May 31, 2018, in Rome after a meeting with Italy's president. Tiziana Fabi/AFP/Getty Images

The key economy ministry went to a mainstream economist, Giovanni Tria, who is close to the center-right Forza Italia party of ex-Premier Silvio Berlusconi. Mattarella had vetoed the 5-Star-League's first proposed candidate for the post because of his euroskeptic views, scuttling their first shot at forming a government.

The Cabinet also includes defense attorney Giulia Bongiorno as the new minister for public administration. A center-right lawmaker, she is legendary for defending ex-Premier Giulio Andreotti against mafia collusion charges and defending the ex-boyfriend of American student Amanda Knox against murder charges.

The ceremony Friday afternoon capped a roller-coaster week of political and financial turmoil that saw stock markets around the world plunge and Italy's borrowing rates soar on the threat of a new election in Europe's third-largest economy.

It also came on the eve of the nation's Republic Day holiday, the day in 1946 when Italy abolished the monarchy and gave birth to the First Republic.

The improbably fast rise of the grassroots 5-Star Movement and its alliance with the right-wing, anti-immigrant League has been dubbed the birth of Italy's Third Republic, after Italy's post-war political order was largely drubbed in the March 4 national vote.

"Look at this spectacle!" marveled 5-Star leader Luigi Di Maio moments before the swearing-in ceremony. In a Facebook post featuring a photo of the 5-Star ministers, he said: "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."

After the ceremony, Conte headed to the premier's office to formally take the reins - and a symbolic little bell - from ex-Premier Paolo Gentiloni.

The changing of the guard sets the stage for obligatory confidence votes in Parliament next week. Between them, the League and 5-Stars have a thin parliamentary majority, and some right-wing lawmakers outside the government have vowed to abstain rather than vote against it.

Europe's populists and right-wingers cheered the new Italian government as a slap in the face to Brussels, headquarters of the 28-nation European Union.

French far-right leader Marine Le Pen tweeted: "It's a victory of democracy over intimidation and threats from the European Union." Le Pen shares the League's firm stances against immigrants.

Nigel Farage, former leader of Britain's UKIP party that played a key role in the Brexit campaign for Britain to leave the EU, wished good luck to the two parties.

"Gotta stay strong or the bully boys will be after you," he warned.

It was a reference to EU officials, who have made clear in recent days their concerns -- in occasionally undiplomatic terms -- about Italy's euroskeptic direction.

European Commission President Jean-Claude Juncker told a conference Thursday that he loved Italy, but refused to accept the frequent mantra by Italian politicians that Italy's ills are the fault of the EU.

"Italians have to take care of the poor regions of Italy. That means more work, less corruption. Seriousness," he said. "We will help them, as we always did. But don't play this game."

His comments sparked outrage in Italy, with Salvini blasting them as "racist" in his victory speech Thursday in northern Lombardy.

"With the new government, we'll see how to make them respect the rights and dignity of 60 million Italians who want cooperation from Europe, not insults," Salvini said.

By Friday, EC spokeswoman Mina Andreeva said Juncker "deeply regrets" the comments and reaffirmed that he not only loved Italy, but that the EU executive was committed to working with its new government.

"We have full confidence in the capacity and willingness of the new government to engage constructively with its European partners and EU institutions to uphold Italy's central role in the common European project," Andreeva said.

The government is headed by Conte, but he has as deputy premiers his two more seasoned political masters: Di Maio and Salvini.

Di Maio, who pledged to give needy Italians a basic income, takes over as economic development minister, while Salvini heads the interior ministry, the key position to enforce his pledge to expel hundreds of thousands of migrants.

Ex-Premier Matteo Renzi, whose Democratic Party suffered its worst-ever thrashing in the March vote, wished good luck to the Conte government while vowing to be the "civil opposition."

"We are radically something else than the majority that supports this government," Renzi tweeted.