The 73-year-old Sicilian, who was backed by Prime Minister Matteo Renzi's centre-left Democratic Party (PD), succeeds the hugely popular Giorgio Napolitano, 89, who is stepping due to old age.
Matteralla's election was seen as a master stroke by Renzi. The premier's backing for the austere, left-leaning Matteralla, who ha crossed swords with former prime minister Silvio Berlusconi, helped both unify the ruling party and send a message to Berlusconi that the government no longer depended on his support to pass reforms.
“Good work, President Mattarella! Long live Italy!”, a jubilant Renzi tweeted.
Pope Francis and US President Barack Obama were among the other leaders to send congratulations.
Mattarella won 665 votes in the fourth round of voting by a 1,009-member electoral college, composed of members of the two houses of parliament — the Senate and the Chamber of Deputies — and 58 representatives of the regions. Ferdinando Imposimato, the candidate of the anti-establishment Five Star Movement of Beppe Grillo, won 127 votes. The threshold for victory at the fourth round was a simple majority, down from the two-thirds majority needed for a win in the three opening stages.
During a brief appearance at the Constitutional Court Mattarella said his thoughts were “first and foremost, on the difficulties and hopes of our citizens.” He then slipped behind the wheel of his small Fiat Panda and drove to the Ardeatine Caves in southern Rome, where occupying Nazi forces massacred 335 Italian civilians in 1944.
“The alliance between nations and peoples defeated the racist, anti-Semitic and totalitarian Nazi hatred of which this place is a painful symbol,” he was quoted by Italian news agencies as saying. “The same unity in Europe and the world will defeat those who want to drag us into a new era of terrorism.”
The president-elect is little known among the general public but is a respected figure in political circles after a 25-year parliamentary career and several stints as minister in governments of the left and right. He entered politics after his elder brother, who was president of the region of Sicily, was murdered by the Mafia 1980.
Renzi's backing for Mattarella was interpreted as the end of the temporary alliance the premier had forged with his disgraced forerunner in order to drive labour market and electoral reforms through parliament.
Mattarella is seen as an “anti-Berlusconi” figure, having switched sides from the political right to the left in the 1990s, partly because of his distaste for the media tycoon, who still heads the opposition Forza Italia party despite a tax fraud conviction.
Berlusconi was reported to be feeling “betrayed” by Renzi. He had ordered his party to cast blank ballots in the vote, but 35 members out of 142 present for voting ignored his orders, signalling a rift within Forza Italia.
“The PD had to show it was the backbone of the system and it did,” Ezio Mauro, editor-in-chief of Italian paper La Repubblica. “For Berlusconi it is certainly a major blow.”
The Forza Italia leader was believed to be hoping for a sympathetic figure to be installed as president to increase his chances of winning a pardon over his criminal conviction which would allow him to return to parliament. Grillo, for his part, mocked the self-effacing president-elect for his “fifty shades of grey”.
Matteralla will be sworn in on Tuesday morning. Elected for seven years, the role of president is mainly ceremonial but can be decisive during political crises over the formation of new governments.
Napolitano announced earlier this month that he was too tired to carry on in the job. He agreed to remain on for a while after the end of his first term in 2013 following a revolt within the PD against former prime minister Romano Prodi, who had been tipped to succeed him.