Two military members of the Cabinet resigned today in protest over the government's weekend legalization of the Communist Party, according to Spanish press reports.

There was no official confirmation of newspaper and press agency dispatches that Adm. Gabriel Pita da Veiga, navy minister, and Lt. Gen. Carlos Franco, air force minister, had quit in disagreement with Premier Adolfo Suarez' decision to end the ban on the party imposed by the late dictator Francisco Franco at the end of the 1936-39 civil war. The admiral is a carryover from Franco's last Cabinet.

Prior to the government's decision - announced Saturday, when Madrid was virtually empty - officers of all ranks warned against granting legal standing to the party, considered the state's No. 1 enemy throughout Franco's long dictatorship.

Several officers, according to Western sources, handed their commanders a letter last week stating that they could not accept the legality of the party.

The military unrest is a text of King Juan Carlos authority as commandering-chief of the country's armed forces and of Premier Adolfo Suarez' political control of the country, which is still deeply divided by memories of the civil war. The king ratified the government's controversial political move as part of the monarchy's program to turn Spain into a democratic state.

Franco's handpicked successor, Juan Carlos, assumed the thron 18 months ago after the dictator's death. The king and the premier collaborate closely in all political decisions.

Late last year the military vice premier Lt. Gen. Fernando de Santiago, was fired from the second highest post in the Cabinet because he opposed policies that would "bring Communists and anarchists back to power." His position, backed by other high-ranking top officers, caused deep divisions within the military establishment.

The king and Suarez have moved senior officers favoring democratization and even legalization of the Communist Party into key command positions. What came as a surprise, however, was opposition to giving Communists full political rights among middle-rank and junior officers.

Lt. Gen. Manuel Gutierrez Mellado, a moderate who is the present vice premier, cut short a visit to the Canary Islands this afternoon following reports that the two ministers had resigned.

He did not arrive in Madrid in time, however, for a meeting of the army's superior council, made up of the country's 18 top military commanders. There was no immediate report on the council's deliberations, but after the session ended a representative was sent to report to the king.

Unconfirmed reports late tonight said the king earlier met with the air force minister and convinced Gen. Franco to withdraw his resignation.

Military and official sources would not comment on developments, indicating that the monarch and the premier were trying to minimize the significane of unrest in the armed forces. As usual, there was tight secrecy on military involvement in politics. The king and the premier have repeatedly issued edicts forbidding political activities by members of the armed forces.

Reports of the resignations were accompanied by rightist civilian demonstrations in Madrid. About 100 cars flying the flags of Spain and of the Falange, Spain's Fascist Party, drove through the city sounding their horns, their occupants hailing the army and shouting Franco's name. Later the motorcade went to El Pardo, Franco's former residence, for a small demonstration.

The party's legalization drew a strong protest from Manuel Fraga, a former Franco minister and the Kings' first interior minister. He called the move, "a veritable coup d'etat, a grave political mistake and a legal farce." Fraga is general secretary of the rightist Popular Alliance Party, a coalition seeking to retain features of Franco's regime.