Italy's 87-year-old President Giorgio Napolitano was re-elected in a desperate bid by lawmakers on Saturday to end a deadlock on forming a new government, with cheers in parliament but jeers at a rally outside called by a protest party.
The ex-communist Napolitano won with a sweeping majority of 738 ballots out of 1,007 possible votes -- far ahead of the 217 received by leftist academic Stefano Rodota whose candidacy was put forward by the anti-establishment Five Star Movement.
"We must all bear in mind, as I have tried to do, the difficult situation of the country," Napolitano said at a brief ceremony in the presidential palace where he was handed the official results of the election.
He called on bickering politicians to "honour their commitments" and said the presidential election process had been "tormented".
Meanwhile hundreds of people rallied in Rome at a protest called by Five Star Movement leader Beppe Grillo, a former comedian who had been scheduled to join the demonstration but later said he would not.
"Jokers!" "Shame!" the protesters shouted.
Grillo's party came third in February elections, shaking up the traditional political system.
In a blog post, he slammed Napolitano's re-election as a "coup d'etat" by the mainstream parties.
Antonio Padellaro, the editor of leftist daily Il Fatto Quotidiano, told news channel Sky TG24 that Napolitano's return reflected the "impotence" of Italian politicians.
"This is in some ways an unacceptable and disconcerting operation," he said, adding that the choice did not reflect the desire for change of many young Italians.
The election brings to an end a chaotic series of votes this week that saw the candidacies of former European Commission president Romano Prodi and former trade union leader Franco Marini rejected and the centre-left tipped into disarray.
The president only on Saturday agreed to stand for an unprecedented second term -- the first Italian president to do so -- after pleas from outgoing prime minister Mario Monti, rightist leader Silvio Berlusconi and leftist leader Pier Luigi Bersani.
Monti said he had called Napolitano to thank him for his "spirit of sacrifice" during "a difficult phase of our nation's life".
He will be officially sworn in on Monday in the lower house of parliament and begin sensitive talks on setting up a new government.
The two scenarios outlined by analysts are either a technocratic government similar to Monti's one or a grand coalition, which would prove controversial among many Italians as it could bring the scandal-tainted Berlusconi back to power.
Napolitano is considered as being above the party political fray and is respected by rival forces, which have been at loggerheads since a general election that yielded no clear winner and left the eurozone's third largest economy in limbo.
Monti's cabinet has limped on with only interim powers since the elections and the reform programme he began has been at a standstill.
European Commission President Jose Manuel Barroso said Napolitano would provide "a decisive contribution to our common European ideal".
Pope Francis also hailed the election saying Napolitano's actions had been "illuminated and wise".
Napolitano as recently as last week had ruled out the prospect of staying on, saying he had "done everything I could" to end the stalemate and saying he was looking forward to his retirement as his seven-year mandate draws to a close.
He is not expected to serve out the full second term but instead only stay in office the time needed to end the deadlock and then resign at the end of a political career that began in the Second World War when he was an anti-fascist activist.
Napolitano was credited with engineering former European commissioner Monti's rise to power after then premier Berlusconi's chaotic ouster in 2011 during a wave of panic on the financial markets.
The Italian presidency is usually a ceremonial role that takes on far greater importance at times of political instability.
The main centre-left coalition led by the Democratic Party (PD) narrowly won elections in February but failed to get enough votes for an overall majority in parliament.
The PD's leadership -- its secretary Bersani and chairwoman Rosy Bindi -- resigned on Friday after the two presidential candidacies they had proposed fell through due to a rebellion from within their ranks.