Most Italians shrugged. We dealt with Silvio Berlusconi for 20-odd years and coped with Matteo Renzi’s youthful self-centeredness. So we were used to political megalomaniacs, long before the United States or Britain. But Mr. Salvini’s behavior lately really is disconcerting. Time on the opposition benches might force him to cool off.

Still, the outcome is not obvious. A new government is likely to be formed, in the next few days. But the Democratic Party and the Five Star Movement are quite different, and so are their voters. If their strange marriage fails, President Mattarella — the coolest head in this whole mess — will have no choice but to dissolve Parliament and call for a general election in the autumn. So Italy is, once again, on the brink — a spot it occupies all too often. Will it manage to take a step back and avoid going over? It might. On three conditions.

First, the political agenda. A government is formed to do something, not to prevent someone else’s rise (even if that someone is Mr. Salvini). The Democratic Party stands for open society, open market, investments, Europe and NATO; Five Star has been toying with conspiracy theories and anti-vaxx propaganda, has ranted against the European Union and supported Nicolás Maduro in Venezuela. The Democrats belong, in most respects, to the new moderate left; the Five Stars borrow many ideas from the old radical left. A good sign is that the most quarrelsome characters, such as Alessandro Di Battista, are not expected to be in the new government. And the outgoing (and incoming) prime minister just took control of the digital transformation of the notoriously labyrinthine Italian Civil Service.

The second condition relates to personal relations within the new coalition. Luigi Di Maio, the nominal leader of the Five Stars, like the rest of his movement, spent most of his political career accusing the Democratic Party of everything under the sun, from corruption to child trafficking. When he realized that joining the Democrats was the only alternative to an early election — in which his leadership and his movement would probably be devastated in the pattern set in recent European elections — and that a lot of Five Star deputies don’t even have a job to go back to, he swallowed his pride and agreed to join forces with his archrivals. But will the rest of the movement follow their leader’s conciliatory attitude? An online vote by Five Star voters — on a party site called the Rousseau platform, a clumsy attempt at “direct democracy” — will deliver an early indication. The same question, of course, should be put to the Democrats, who have long considered the Five Stars aggressive and incompetent amateurs.

The third condition relates to Mr. Conte himself. Provided that the appointed prime minister overcomes the personal ambitions within his supporting parties — Luigi Di Maio is sulking because he wants to keep his rank of deputy prime minister — Mr. Conte must grow further into his new shoes. True, he stood up to Mr. Salvini in the Senate, accused him of disloyalty and bluntly confronted him on a string of thorny issues, including a continuing investigation into reports that Russia contributed to funding the League. But for one year he seemed powerless and sometimes hopeless — a figurehead with no real power, an obscure law professor chosen to mask the differences between the coalition strongmen. Now he’ll be a prime minister with growing support in the country and the backing of Italy’s president. If he acts like a prime minister, who knows? Italy may have found a new government with some badly needed stability, led by an unexpected statesman.