By Steve Scherer and Paolo Biondi
ROME (Reuters) - Italian lawmakers elected Sergio Mattarella, a constitutional court judge and veteran center-left politician, as president on Saturday, handing a welcome political victory to Prime Minister Matteo Renzi.
Mattarella, speaking at his office in the Constitutional Court after the vote, said: "My first thoughts are of the difficulties and hopes of our citizens."
He later visited the site in Rome where German troops killed 335 Italians in World War Two, saying that Europe must unite to battle terrorism the same way allied nations banded together to defeat "Nazi hate, racism, anti-Semitism, and totalitarianism".
The election shows the 40-year-old Renzi in firm control of both his fractious party and his allies in the ruling majority as he seeks to pass reforms aimed at underpinning an economic recovery in Italy, where unemployment is soaring after six years of on-off recession.
After three inconclusive rounds of voting this week in which a two-thirds majority was needed, his candidate Mattarella was elected in the fourth round, when the required quorum fell to a simple majority.
As the ballots were counted out loud in the Chamber of Deputies, the 1,009 parliamentarians and regional officials eligible to vote burst into applause when Mattarella's name surpassed the 505-vote threshold, making him Italy's 12th president since World War Two.
Mattarella, 73, who is little known to most Italians, got 665 votes. He will be sworn in on Tuesday at 10 a.m. (0400 ET) for a seven-year term, taking over from 89-year-old Giorgio Napolitano, who resigned earlier this month.
"Keep up the good work, President Mattarella. Long live Italy!" Renzi tweeted after the vote, while Pope Francis sent his congratulations by old-fashioned telegram.
The Italian president is a largely ceremonial figure, but he wields important powers at times of political instability, a frequent scourge in Italy, when he can dissolve parliament, call elections and pick prime ministers.
Center-right rival Silvio Berlusconi's Forza Italia party appeared in disarray after the vote.
Berlusconi ordered his party to cast blank ballots after accusing Renzi of betraying what he said was a promise to give him a role in choosing the candidate. Instead, more than 30 refused, opening a wound in the party.
Renato Brunetta, Forza Italia's chief whip in the lower house, said the pact that Renzi and Berlusconi sealed last year to make institutional reforms was dead, but not all his party colleagues were so resolute and Berlusconi himself has yet to comment.
"Renzi made a unilateral decision to break the pact," Brunetta said. "Nothing will be the same now."
Mattarella is the first native of Sicily to become president. He has a reputation for being a reserved but straight-talking former constitutional law professor, whose career in politics began after his brother, Piersanti, was shot dead by the Sicilian Mafia in 1980.
Mattarella's political roots are in Italy's defunct Christian Democrat party that his father Bernardo, an anti-fascist, helped to found after the war.
Though Mattarella is not seen as having vast international experience, he did serve as defense minister in two different center-left governments, from 1999 to 2001.
In 1990, Mattarella resigned as education minister to protest a decree that favored Berlusconi's media empire, and three years later he drafted a voting law, which has since been changed, that was used when Berlusconi won his first of three national elections in 1994.