ROME, Italy — His adversaries probably know it better than his allies: Silvio Berlusconi is at his best when he feels he has to fight for his life.

Italy's embattled prime minister has today shown just how true this is, managing to survive a key confidence vote on his center-right government, even if by a razor-thin majority of only three votes. But as celebrations for his victory were breaking out among his supporters in parliament, riots erupted between protesters and police in central Rome, a sign that his support in the country is waning.

The no-confidence motion against Berlusconi's government, presented by his former ally Gianfranco Fini, speaker of the chamber, was defeated by 314 votes against 311: a slim margin by all accounts, and still one vote short of an outright majority in the 630-member lower chamber.

This means that — after a months-long crisis that has stalled government activity during the key months of the European financial crisis — Berlusconi will likely have difficulty pushing through reforms to reduce unemployment, raise productivity and chip away at what has become the highest public debt in Europe, which today reached a record high.

The protesters — students angry at the heavy cuts in education spending, victims from the L'Aquila earthquake still waiting for their houses to be rebuilt, trade union activists and others — had been filling the streets around Italy's heavily-guarded parliament building since the early hours of Tuesday morning as lawmakers gathered for the confidence vote.

As news of Berlusconi's success spread, the mob became enraged, clashing violently with police in full anti-riot gear. Cars were set ablaze and shop windows were smashed as the smell of tear gas and burned tires spread through the city’s streets. Most of Rome's historic center was paralyzed for hours.

Police blamed the riots on extremist groups, dubbed by Italian police as “black blocks,” which were small but well organized.

The anger vented during Tuesday’s demonstrations runs deep among those Italians who strongly resent Berlusconi's leadership, his scandals and personal style.

Instead, Berlusconi proved once again that he is the quintessential comeback kid of Italian politics. He first managed to woo two deputies in the most unlikely quarter: the Italy of Values party, whose leader, former anti-corruption prosecutor Antonio Di Pietro, is by far his strongest critic in parliament.

Then, after a frantic round of meetings and amid allegations of corruption by the opposition, three lawmakers turned their back on Berlusconi's bitter rival — lower house speaker Gianfranco Fini — and returned to Berlusconi's fold. It was a dramatic twist welcomed by loud shouts and cheering among lawmakers.

Their vote was decisive, and the prime minister had, once again, narrowly escaped defeat.