Italy has re-elected President Giorgio Napolitano for a second term following a last-minute deal between party chiefs to break the deadlock after five previous ballots failed to produce a winner.
With the support of all major parties, except the 5-Star Movement, Napolitano easily won the vote on Saturday, which required more than 50 percent of votes in a special sitting of both houses of parliament.
Napolitano, who at 87 is already among the world's oldest heads of state, may not serve the full seven-year term and could resign after the political stalemate that has lasted since an inconclusive February election is solved.
Earlier on Saturday, Napolitano had put forward his candidacy for another term as Italy's president after the main political parties appealed for him to help resolve a deepening crisis.
"I consider it necessary to offer my availability," Napolitano said in a statement after no candidate won a majority of votes in the joint session of parliament.
Stefano Rodota, an academic and human rights advocate who is the candidate for former comic Beppe Grillo's left-wing Five Star Movement, received the highest number of votes with 210 of the required 504 ballots.
The deepening crisis comes after politicians from the main parties said they would either not participate or would cast empty ballots earlier on Saturday, after Pier Luigi Bersani, the leader of the Democratic Party (PD) announced he would resign once a new head of state was elected.
The PD has been in turmoil after both candidates proposed by Bersani, former trade unionist Franco Marini and then former European Commission president Romano Prodi failed to be elected in voting on Thursday and Friday.
Al Jazeera's Claudio Lavanga, reporting from Rome, said Napolitano only made the decision because of the current political gridlock.
"This has never happened in the history of the republic," Lavanga said. "Since 1946, no president has carried on with a second mandate. But obviously, this time, there's not been any other solution".
Our correspondent also reported that opposition politician Grillo has called on his supporters to hold a protest outside the parliament building later on Saturday.
Bersani had backed former premier Prodi, who fell well short of getting enough support in voting on Friday. As voting takes place in secret, deputies are not obliged to toe a party line.
Until the vote, former European Commission chief Prodi had been considered the frontrunner for the job, but the right refused point-blank to support a politician who has twice inflicted election defeats on centre-right leader Silvio Berlusconi.
Leftist voters numbering 101 also opposed him, leaving him with just 395 votes - well short of the 504 needed to win.
Bersani's selection of Prodi had marked a dramatic about-turn, after he failed on Thursday to impose 80-year-old former Senate speaker Franco Marini on the centre-left as presidential candidate under the terms of a deal with Berlusconi.
"He accepted his responsibility after the disgrace of what happened," Paolo Gentiloni, a senior PD parliamentary deputy said after Bersani's announcement that he would resign following the election of the new president.
The political impasse caused by February's inconclusive general election has stoked concern about stability in the recession-hit country, the eurozone's third largest economy.
The disarray in the centre-left, which has the most seats in parliament, could make a snap election in the summer more likely in a bid to end the impasse, but there is no clarity about the next moves after weeks of chaos.
Berlusconi, welcoming the news that Bersani was stepping down, said his party would also abstain from Saturday morning's vote if the left and the right could not agree on a candidate.
The presidency, an office elected by parliamentarians and regional representatives, is a largely ceremonial position, but is important at times of political instability like the present, when the president plays a major role in forming a government.
Napolitano had been unable to find a way out of the crisis with his powers restricted at the end of his mandate.
In the final months of his mandate Napolitano was constitutionally prevented from dissolving parliament and calling fresh elections.