ROME — Italy’s president on Wednesday cleared the way for the populist parties that won the most votes in elections two months ago to govern together, a step that seems certain to make Italy by far the largest and most important member of the European Union to be run by populist forces and grant a big victory to the bloc’s antagonists.
The Five Star Movement, which began as a web-based protest against the political establishment, and the League, a hard-right party that has campaigned on an Italians-first platform, agreed last week on a governing agenda that would crack down on illegal immigration, challenge budget rules from Brussels and lift sanctions against Russia.
On Wednesday, after 80 days of arduous talks, President Sergio Mattarella gave a mandate to form a government to the parties’ consensus pick for prime minister, Giuseppe Conte, a little-known lawyer with no government experience. Critics assert he would be a pawn of the populist party leaders.
Mr. Conte, in blue suit, white shirt and checked tie, walked into the Quirinal Palace shortly before 5:30 p.m. in Rome. Ushers in formal dress shook his hands and brought him to the president’s office.
Nearly two hours later, a top Quirinal official announced that Mr. Mattarella had asked Mr. Conte to try and form a government and that Mr. Conte had accepted. “I will be the defense lawyer of the Italian people,” Mr. Conte said upon emerging.
Matteo Salvini, 45, leader of the League, surrounded by a scrum of reporters on the street as Mr. Conte met with the president, said the incoming prime minister would have “full” autonomy. He also said that for Mr. Conte, like for him, “the well being of Italian citizens” came before European considerations.
Supporters and critics of the parties agreed that the prospect of populist and hard-right forces running Italy — the birthplace of Fascism, a founding member of the European Union, and the bloc’s fourth-largest economy — was a remarkable moment on the Continent. It was also one all but unforeseen even four years ago, when Europe looked to Italy as a bastion of liberal values and center-left politics.
The turnabout has not only shattered Italy’s decades-old party system. It is also certain to give new energy to nationalist impulses and move the greatest threat to the European Union’s cohesion from newer member states on the periphery, such as Hungary and Poland, to its very core.
“The wave of populists and anti-establishment forces is still on, and this will continue for the foreseeable future across Europe,” said Wolfango Piccoli, a political analyst and co-president of Teneo Intelligence.
Mr. Conte now needs to present his cabinet choices to Mr. Mattarella, who has the power to reject individual ministers and is wary of the empowering antagonists to the euro. But such a step is rare, and it is likely that Mr. Mattarella will approve the new government in the coming days.
Most worrying to many is the threat the new government’s agenda could pose to Italy’s finances: Analysts said the governing agreement announced last week was a potential budget-buster.
Italy’s economy accounts for more than 10 percent of the European Union’s total output and is the bloc’s second-most-productive manufacturer.
But it also among the slowest growing economies in Europe, and its enormous government debt — about 130 percent of gross domestic product — makes it too big to bail out. If the Italian economy crashed, the European economy could tank, too.
Markets have already shown jitters about a populist government, and bond yields continued to climb this week. On Wednesday, European Union officials made it clear that they expected Italy to meet its financial obligations.
“Our political message is very clear,” said Valdis Dombrovskis, vice president of the European Commission, the bloc’s executive arm. “Italy needs to continue to reduce its public debt, which is indeed second highest in the E.U. after Greece.”
Mr. Conte’s debut on the national stage on Monday was not entirely smooth. Apparent exaggerations in his résumé, first reported by The New York Times, set off a deeply politicized debate about whether he should serve as prime minister.
But the populist leaders, Luigi Di Maio, 31, of the Five Star Movement, and Mr. Salvini, stuck with him, saying the alternative to Mr. Conte was new elections.
Five Star leaders also applied pressure, warning Mr. Mattarella against blocking the will of the people.
The 11th-hour deal between the two parties came after weeks of intense, and sometimes secretive, meetings between Mr. Di Maio and Mr. Salvini after the president threatened to impose a technocratic caretaker government.
The party leaders’ ambitions to become prime minister seemed the biggest obstacle. But once that was set aside in favor of backing Mr. Conte, their alliance made electoral sense. The parties together won half of the Italian vote in March: Five Star received a third of the vote, and the League won 17 percent.
Both parties had spent the campaign demonizing, in often vulgar terms, the center-left government, the center-right establishment, the meddling of the European Union and the invasion of migrants.
The most hostile attacks often took place on social media, where both parties and their leaders are fluent, but where the Five Star Movement is a pioneer that has made Italy a laboratory for experiments with web-based democracy and viral messaging. Brussels was a frequent target.
“Italy has voted the first anti-European, no-Europe government among the countries that founded the European Union,” said Sergio Fabbrini, the director of the School of Government at Luiss Guido Carli University in Rome. “I see instability, not stability, ahead.”
In recent weeks, however, Five Star and the League modulated that message — especially after a draft of their government agenda was leaked, including proposals about leaving the eurozone and asking the European Central Bank to cancel 250 billion euros, or almost $300 billion, in Italian debt.
The document jolted the markets and, perhaps even more important, made Mr. Mattarella nervous. It was quickly amended, and the party leaders moved to assure international observers that things would be fine.
Often the populist leaders seemed to be performing for an audience of one. But Mr. Mattarella’s power, absolute during the crisis, would transfer to the new government once its leaders took office.
Mr. Fabbrini said that government could move Italy beyond its traditional West European partners and closer to countries like the Czech Republic, Hungary and Poland that are increasingly challenging the European Union.
“This is a group that would rather hollow it out from the inside, demanding more power over immigration, control of the border, a more loose stability and growth pact,” Mr. Fabbrini said. “It’s a more insidious coalition.”
Under a Five Star and League government, Italy would be by far the largest voice of such a group, an unwelcome development for officials in Brussels. But the cold shoulder those leaders gave to Italy’s outgoing center-left government on migration only fueled anti-migrant anger that benefited the populists.
As the migrants kept coming, the anti-migrant League grew stronger. The Five Star Movement also took a harder line, though its core message addressed the economic frustration of young Italians, especially those in the economically depressed south.
Despite its difficulty governing cities, such as Rome, Five Star has gained electoral strength, in part because its studied vagueness on controversial issues has avoided alienating voters on the left and right.
Many Italians are unclear where it stands. Its leaders have questioned the country’s membership in the eurozone, supported it, and recently questioned it again. They say they want Italy to be more balanced in its foreign policy, but have grown closer to President Vladimir V. Putin of Russia. Their position on the dangers of vaccines keeps changing.
Party leaders attribute those changes to what they call direct democracy, expressed in online clicks of members who decide policies and candidates. Critics have instead raised questions about Davide Casaleggio, the son of the party’s late founder and an unelected businessman who controls Five Star’s web platform.
The alliance’s governing contract was ratified in recent days by the parties’ bases. It includes proposals that critics say have the potential to erode Italy’s representative democracy, such as banning members of Parliament from switching parties, or from dissenting from the party line.
The League, a more traditional right-wing party with formal associations with France’s National Front and Mr. Putin’s Russia United Party, started as a northern separatist movement.
But under Mr. Salvini, the League’s traditional theme — the excoriation of the work ethic of Italian southerners — switched to rallying Italians against the invasion of African migrants from the south and the meddling of Brussels bureaucrats from the north.
Sofia Ventura, a professor of political science at the University of Bologna, said the new coalition was a “mixture between ideology and incompetence.”
But Europe’s populists welcomed the new alliance warmly.
In an article published on Wednesday in the newspaper Corriere della Sera, Marine Le Pen, the leader of the National Front in France, said that the “Europe of nations is close at hand” and heralded the new government as a harbinger for the collapse of the European Union.
Nigel Farage, the former leader of the UK Independence Party who helped lead the campaign for Britain’s withdrawal from the European Union, has relished the prospect of the Italians giving the Germans a headache.
Stephen K. Bannon, an architect of the election of President Trump who said he had kept in close contact with League leaders, also welcomed the “historic” alliance with Five Star.
“First anti-establishment government in Europe,” he said in an interview, saying more would come. “First government built on populism and nationalism as its foundation.”
Elisabetta Povoledo contributed reporting.