Veteran Socialist Sandro Pertini, 81, a former anti-Fascist freedom fighter and wartime resistance hero was elected president of Italy yesterday in a landslide victory ending 10 days of political fighting.

Pertini's election by an unprecedented 83.6 percent majority came on the 16th ballot and followed a surprise reversal Friday by the ruling Christian Democrats, who previously had opposed the Communist and Socialist-supported candidate.

It was the first time in modern Italian history that a presidential candidate won the support of all of Italy's political parties with the exception of the two far-right neofascist groups. It was also the first time a Socialist had been elected head-of-state of post-war Italy.

The Christian Democrats' about-face ended the deadlock caused by the failure of Italy's three major parties to find a consensus candidate, which was subjecting the current Christian Democratic-Communist alliance to serious strains.

By yielding to an inflexible Socialist demand, the Christian Democratic turnaround provided a new lease on life for Premier Giulio Andreotti's leftist-supported government that took office in mid-March.

Pertini's election to the largely ceremonial position was greeted by a standing ovation from the vote-weary deputies senators and regional representatives who had been trying since June 29 to elect a successor to Giovanni Leone, a Christian Democrat who resigned because of corruption charges on June 15 six months before the end of his seven-year term.

Leone, who had not voted in any of the previous 15 ballots made an unexpected appearance in the Chamber of Deputies yesterday to vote for Pertini.

"I have come to cast my vote for a gallant and upright man whom I have known for 30 years," he said.

An emotional Pertini watched the balloting on television from his office at the parliament.

"I felt more calm when I had to face Mussolini's special tribunal," he said referring to his 1926 trial for anti-Fascist activities.

Pertini got 832 votes out of a total of 995 cast but as soon as the total passed the 506 votes needed to win, he was congratulated in his office by other politicians incluing the former Socialist leader, Pierto Nenni, 87, who described Pertini as "eloquent, passionate and hot-tempered."

Pertini, whose real name is Alessandro, was born in Savona in northern Italy in September, 1896, and after studying law and political science, decided to become a journalist, and then a socialist.

Guards from the now-empty Quirinale Palace which Leone vacated on the day he resigned were immediately sent to guard the nearby building around the corner from the Trevi Fountain where Pertini and his wife Carla live.

Congratulatory messages, many of them addressed to "Comrade Sandro Pertini", poured in from around the country indicating that for the first time Italy may have found itself a president with significant popular and working-class support.

The new Socialist president's six predecessors include two right-of-center Liberals, three Christian Democrats and a Social Democrat. Giuseppe Saragat, whose 1964 election came two years after the ground-breaking "opening to the left" alliance between the Christian Democrats and the Socialists.

Pertini's election comes exactly two years after the Christian Democrats first began their present de facto alliance with the powerful second-place Communists. It puts an end to ten days of tensions that strained that alliance, which had already been put to the test by the terrorist murder of former premier Aldo Moro, who was originally slated for Pertini's new job.

Tensions were so high during the first nine days of the election contest that Communist Leader Giancarlo Pajetta said: "the political picture may be intact but the wall on which it is hanging has collapsed."

The Italian president's powers include appointing a new prime minister when a government falls and dissolving parliament and calling new elections when it proves difficult or impossible to form a new government.

Both the Communists and the present leadership of the Christian Democratic Party believe Pertini will favor continuation of the status quo. The Communists also feel that he would be unlikely to call new elections merely to keep them for getting into an Italian government.

Moro's death left the Christian Democrats without a candidate and gave Socialist leader Bettino Craxi the chance to insist that it was his party's turn to hold the post which is largely ceremonial but which can become crucial in times of government crisis.

Early on in the election, Pertini appeared to be the candidate most likely to win broad support at a time when growing terrorism and economic instability make political consensus a prime concern here.

The Christian Democrats first rejected Pertini's candidacy because it had been proposed by the left without prior consultation. Pertini withdrew his candidacy for the same reason, clearing the way for the Christian Democrats' decision to present his name when it became clear that agreement on any other candidate was impossible.

The irony is that Pertini, a loner who has often differed with his party, was not the Socialists first choice. But it was precisely his independent personality that made the pipe-smoking octogenarian more acceptable to the Communists, whose support was essential, than any of the other Socialists proposed.