MILAN (AP) — Italy’s anti-establishment 5-Star Movement and the right-wing League succeeded Thursday in forming western Europe’s first populist government, which will be headed by a political novice whose first try was rejected four days earlier as too risky for the Italian economy.

What changed was the willingness of 5-Star leader Luigi Di Maio and League leader Matteo Salvini to shuffle the proposed roster of government ministers amid a financial market scare. They moved an 81-year-old euroskeptic economist vetoed by Italy’s president from overseeing the economy ministry to a European affairs Cabinet post.

After the fits, starts and financial turbulence of recent days, the realization of a 5-Star-League coalition government put its populist posture on full display in Salvini’s first public remarks. He returned from Rome to address a crowd of supporters in his northern home region of Lombardy.

“I want to make Italy a protagonist in Europe again. With good manners and without creating confusion. But I am fed up of governments with the hat in their hand,” Salvini said to cheers. “We are second to no one.”

Just a short time earlier, President Sergio Mattarella’s office announced that the new premier, University of Florence law professor Giuseppe Conte, and his ministers would be sworn in Friday afternoon.

It was a stunning comeback from Sunday evening, when Conte — the premier-designate at the time — left a meeting with Mattarella empty-handed and returned to his teaching job.

Emerging from a similar meeting with a different ending Thursday night, Conte read off his Cabinet list and pledged that “we will work with determination to improve the quality of life of all Italians.”

The Cabinet includes Di Maio— architect of the government’s proposed basic income for struggling Italians — as welfare minister and Salvini — who has pledged to expel hundreds of thousands of migrants — as interior minister.

The new economics minister, Giovanni Tria, is a mainstream economist at Rome University, while the foreign ministry goes to Enzo Moavero Milanesi, a former European Union official in Brussels who was European affairs minister in former Premier Mario Monti’s two-year technical government.

In his remarks to supporters, Salvini pledged to make sending migrants back to their home countries a priority.

“My commitment will regard the security of 60 million Italians,” Salvini said.

Di Maio kept his comments to a brief Facebook post thanking supporters and declaring “the government of change is reality.”

An inconclusive parliamentary election in March produced months of stalemate before the Italian political machinery went into overdrive this week. After rejecting Conte’s first attempt, Mattarella tapped a former International Monetary Fund official to head a possible interim government of technocrats to see Italy through to an early election.

But investors, fearing the vote would be a referendum on the euro, revolted, sending Italian stocks plummeting and increasing the cost of borrowing to cover Italy’s stubbornly high sovereign debt of 132 percent of GDP. Just the prospect of a political government calmed markets Thursday.

Mattarella put that premier-designate, Carlo Cottarelli, on hold after the 5-Stars and the League indicated willingness to compromise on their ministers. Di Maio also backed down on threats to seek Mattarella’s impeachment over the first failure.

The two leaders canceled other engagements Thursday to meet at the parliament in Rome and hammer out a Cabinet.

With developments moving quickly, Cottarelli stepped aside and Mattarella summoned Conte, who had returned to Rome earlier in the day after turning over his morning class to a substitute.

Mattarella received a round of applause from the press room at his palace when he described the recent events as “this complex itinerary that led to the formation of a government.”

During the first attempt to put together a populist government, Salvini and Di Maio’s decision to tap an unknown lawyer to be the next premier raised eyebrows in Italy. The revelation that Conte’s resume exaggerated academic credentials at elite universities in Europe and the United States did not help.

But more fundamentally, analysts have raised questions about whether he would be at best an executor for the two leaders who put aside their ambitions to be premier in order to form a government, and at worst a mediator

Lorenzo Codogno, a former Treasury official and economic analyst, said he predicts “trench warfare” between the government and Mattarella “on matters related to Europe and the fiscal stance.”

“Still, it is well possible that the near-term financial market reaction is positive, as (the) breakthrough reduced the uncertainty and at least provides Italy with a much-needed government,” he said.