Portugal made a major turn to the right in parliamentary elections today, marking an end to five years of postrevolutionary unrest, parliamentary instability and cabinets running the gamut from pro-communist to moderate center-left.

With 96 percent of the vote counted, a recently formed alliance of three rightist and center-right parties, the Democratic Alliance, was winning more than 45 percent of the vote. This is enough to set a parliamentary majority under Portugal's proportional representation system that gives the leading party extra seats in the 250-member parliament.

This represented a combined advance for three parties in the alliance.

The other big winner was the Communist Party, which increased its share of the vote to 19 percent from 14.6 percent in the last parliamentary elections in 1976.

The big losers were former premier Mario Soares's Socialists, down in the partial returns from 33.8 percent to 27 percent in districts representing 3.8 million of Portugal's 7 million registered voters.

The Democratic Alliance picked up votes in the leftist South of the country, while the Communists made inroads in the conservative, Roman Catholic, traditionalist North.

In addition to the squeeze on the Socialists between the two extremes, the election results represented a major setback for the political position of President Antonio Ramalho Eanes.

Democratic Alliance leader Francisco Sa Carneiro, 43, has made it clear that, as a premier with the first clear parliamentary majority since the Portuguese revolution of 1974, he would reduce Gen. Eanes to a figure-head president.

In the face of this, Eanes has sought a reconciliation with Soares. The two men had been feuding since the president dismissed the Socialist leader as premier last year, when Soares tried to hang onto power after the desertion of a rightist coalition partner ended his majority in parliament.

After Soares' dismissal, Eanes appointed a succession of three nonpartisan premiers. Since none of them was able to form a lasting parliamentary majority, Eanes called for elections a year ahead of time. The new parliament must be dissolved soon, however, since Portugal's constitution calls for national elections by the end of 1980. With the president's own term expiring in the spring of 1981, Portugal seems bound to be subjected to electroal fever for the next 18 months.

While some observers assume that a Sa Carneiro government will have to tread lightly because of the need to return to the voters next year, one informed political source said that the alliance leader has already made up his mind to keep hacking away at Socialist voting strength by passing a number of leftist-oriented measures. The reasoning behind this approach would be that the voters of the right would be forced to accept the switch since they have nowhere else to turn.

In addition to squeezing the Socialist Party, today's results also appear to spell at least a temporary end to Eanes' attempts to shift Portugal from parliamentary to presidential-style democracy.

With reputation for political showmanship, Sa Carneiro is a lawyer from the northern Portuguese metropolis of Oporto, the country's second largest city after Lisbon, and the historic rival of the capital.

Sa Carneiro has said that he opposes the election of another soldier-president. As the candidate of the Armed Forces Movement that conducted the 1974 revolution ending almost a half century of dictatorship founded by Antonio Salazar, Eanes won 61 percent of the vote.

The current changes in the Portuguese political kaleidoscope appear at least for now to have deprived Eanes of the possibility of running once again as a nonpartisan candidate. Under present circumstances, it would be hard for him to counteract the impression that he would, in effect, be running as the Socialist candidate. Many observers think he might withdraw altogether rather than accept that situation.

Last week, Soares went to the presidential palace for a much-publicized private dinner with the president. Then came a series of last-minute statements by Eanes, interim Premier Maria de Lourdes Pintasilgo and four members of the Revolutionary Council that presided over the transition to democracy appealing in thinly veiled terms for a Socialist vote.

This rallying in defense of the Socialists was in apparent response to the building conviction that the Democratic Alliance formed during the summer was about to sweep everything before it.

Under Soares' leadership, the Socialists have experienced a steady decline from the 38 percent of the vote they got for the Constituent Assembly soon after the revolution to 35 percent in the voting for the first regular parliament in 1976, to today's result.

The parties of the Democratic Alliance are Sa Carneiro's Social Democrats, the Center Democrats of Dioso Freitas do Amaral and the tiny Popular Monarchist Party. The three alliance parties won a total of nearly 41 percent of the vote in the 1976 election. The electoral system is set up so that 44 percent was calculated in this election to be enough to give the Democratic Alliance a bare parliamentary majority.

The alliance was not only given a boost by the enthusiasm its new-found unity created, but also by the action of the Roman Catholic Church. Priests preached from the pulpit that it was a sin not to vote, and that ballots shold be cast only for parties that respect the Catholic Church.

It was the Catholic Church's first major intervention in Portuguese politics since 1975, when it was silenced by accusations that it had been one of the main supports of the dictatorship founded by Salazar.

The Catholic Church's move promped Socialist leader Soares to try to erase his party's anticlerical image by holding up a Bible at election meetings. Communist leader Alvaro Cunhal stressed that many Communists are also good Catholics.

While the Socialist Party was being squeezed from the right, the Communists were pursuing their long-range strategy of displacing the Socialists as the leading party of the left. Communist leader Cunhal apparently wants to follow the same route as the Italian Communists, who have reduced Italy's Socialists to a marginal role and have become the main opposition force in Italy.

By coming to campaign for Cunhal, despite the Portuguese leader's image as the leading unreconsructed Stalinist in Western Europe, Italian Communist leader Enrico Berlinguer gave the Portuguese Communists the stamp of approval of the continent's most successful Eurocommunist party. The Italian party has an image of responsibility, moderation and independence from the Soviet Union.