Mario Soares, founder and head of the Portuguese Socialist Party, resigned his post as leader of the country's main opposition party yesterday. His surprise move significantly affects the December presidential election and creates a major crisis in Portugal's major noncommunist left-wing party.

Soares'resignation came after he failed to persuade fellow executive members of the Socialist Party in a day-long meeting to endorse his personal withdrawal of support for President Antonio Ramalho Eanes in his reelection campaign for a second five-year term. The presidential election is scheduled for Dec. 7.

By withdrawing his support, Soares has aimed what some commentators termed a body blow at the campaign of Gen. Eanes. The president is opposed by a fellow general who has the backing of Prime Minister Francisco Sa Carneiro, leader of the ruling right-wing Democratic Alliance coalition that won legislative elections two weeks ago by a comfortable majority.

Soares, twice prime minister and a key figure in Portugal since the 1974 revolution that overthrew a 50-year-old right-wing dictatorship, is one of the country's best-known politicians.

Soares told Eanes he was withdrawing his support in a letter over the weekend in which he alleged that the general, elected with support from all major parties in 1976 and lately fully backed by the Socialists, had shifted to the right. The Socialist leader stepped down after he failed, in a 20-hour meeting, to carry a majority of the 130-member national commission of the Socialist Party. Soares turned party power over to a caretaker leadership pending an extraordinary Socialist congress.

His resignation threw into disarray the campaign plans of Eanes, who had planned his campaign on an appeal to Portugal's centrists.He has styled himself as the president of all Portuguese, but counted on the wholehearted support of the Socialists. A presidential spokesman said Eanes had received news of Soares' resignation "with sorrow." A leading Portuguese analyst was quoted as saying that the presidency has been "handed on a plate" to rival candidate Gen. Antonio Soares Carneiro, a little-known anticommunist commando chief, who is no relation either to Soares or to his promoter, Prime Minister Sa Carneiro.

By failing to gain the endorsement of his party executive, Soares has effectively split the organization that he founded in exile in Paris the year before the revolution and which emerged, in the post-coup period, as the arbiter of Portuguese politics before the current swing to the right pushed it into opposition.

Sixty percent of the Socialist national executive were reported to have voted against Soares' anti-Eanes stand on the ground that Eanes was a safeguard against further polarization of Portuguese politics. Lined up against Soares were the so-called "technocrats" of the Socialist Party. More radical leftists were said to be planning rallies to support Soares and urge him to stand as a civilian presidential candidate.

Soares' aides said that he would take a holiday abroad and not return to Portugal until after the presidential vote.

Soares' is reported to have been bitterly angered by an election statement by Eanes last week in which he aligned himself with the policies of the ruling Democratic Alliance, publicly attacked the Communists, Portugal's third largest party, and appeared to disparage the support that he had hitherto received from the Socialists.

The Democratic Alliance leadership, fully behind Soares Carneiro's presidential candicacy, denounced Eanes' statement as opportunistic. Prime Minister Sa Carneiro is a principal opponent of Eanes, who he says is a front man for the left wing. The subsequent stand taken by Soares leaves Eanes bereft of support from Portugal's main political personalities since he has already alienated the Communist left.