The Spanish Army's deputy chief of staff, who negotiated for the king during Monday night's coup attempt and was considered one of his most loyal officers, was abruptly dismissed today amid widespread speculation that the parliament takeover was part of a military plot involving top commanders.

The attempt failed mainly because the generals misjudged the depth of King Juan Carlos' misjudged the depth of King Juan Carlos' commitment to the democratic constitution developed in Spain's five-year transition from the dictatorship of generalissimo Francisco Franco, according to reports from foreign diplomats here and Spanish politicians and journalists.

The liberal afternoon newspaper Diario 16 created a major sensation with a front-page banner on its final edition saying that the dismissed deputy chief of staff, Gen. Alfonso Armada, "was the key figure in the coup." The story said that unimpeachable political and military intelligence sources had identified him as playing a key role and possibly acting as the "mastermind."

This sensational allegation, which 'madrid's major morning papers were planning to spell oujt in detail, was published shortly before the parliament met to contrinue the business that was interrupted Monday night when Lt. Col. Dantonio Tejero Molina stormed into parliament -- designation of a new premier to replace Adolfo Suarez.

In what appeared as something of an anticlimax to the past three days' events, Suarez's deputy premier, Leopoldo Calvo-Sotelo, won confirmation by a vote of 186 to 158 in the 350-member lower house. The vote that was being conducted Monday was made necessary because Calvo-Sotelo fell seven votes short of a majority on the first try the previous Friday.

Reliable Spanish political and military sources said that in a conversation between Armada and the king about 90 minutes after parliament was taken over, the general told Juan Carlos that there was widespread miltary support for a putsch but that it could succeed only if the monarch agreed to go along. The king replied that the plotters would have to kill him first, these sources said.

Juan Carlos was quickly called by two of Spain's nine captains-general, who serve as regional commanders. The two, commanders of Catalonia and the Basque country, headquartered in Barcelona and Burgos, immediately rallied to the king, according to a version of the calls made public by the Barcelona commander.

Capt.-Gen. Jaime Milans del Bosch of the Valencia region, meanwhile, went over to the rebellion, proclaiming a state of emergency suspending democratic freedoms in his region. He was arrested late yesterday for "repeated disobedience to orders" Monday and Tuesday.

After getting the backing of the Catalonia and Basque area commanders -- controlling Spain's two most industrialized and autonomy-minded regions -- the king called the armed forces joint chiefs of staff into session Monday evening. According to the reports from Spanish political sources, he asked them to call the six remaining captains-general, but the chiefs hesitated to do so for at least two hours. The six regional commanders in any case remained silent about the coup far into Tuesday morning.

The takeover of parliament was at 6:30 in the evening, and the king did not go on the air to order the military to obey him for almost seven hours, presumably because he was still counting his supporters.

Armada was only recently appointed to the post from which he was fired today. He was moved from a provincial command and named a few days after Suarez resigned Jan. 29.

Reports circulating among foreign deplomats and Spanish politicians for some time say that Armada was part of a group, including prominent business and banking figures, advocating a stop to what they regarded as rot in the state from excessive grants of autonomous powers to Spain's regions and lack of vigor in the struggle against terrorism. The conservative newspaper ABC advanced Armada's name for premier three weeks ago.

Although no concrete evidence has surfaced, veteran observers here infer from the fact that Armada was named the mediator between the king and Tejero inside the parliament at Tejero's request, and the fact that no one else showed up in parliament who could have been the "competent military authority" promised by Tejero, that some officers wanted Armada to be voted in as premier Monday evening by the hostage deputies.

Reliable sources say that while there was nothing in Armada's behavior to make the king immnediately suspicious, Juan Carlos got alarming reports about the way he was conducting the negotiations with Tejero. Armada was replaced as the go-between with Tejero about midway through the 18-hour captivity of parliament.

Other indications from military behavior at a more subordinate level in the Madrid region show that a number of officers were involved. For instance, the former commander of the Madrid region's key Brunete Armored Division, who was transferred a year ago after rumors of involvement in plotting, reappeared at division headquarters Monday morning and met with his old staff.

Various elements of the division played roles in the plot such as briefly taking over the state radio and television and reinforcing the Civil Guard captors in the parliament building with a unit of white-helmed military police.

Tejero, in what was then interpreted as bragging or wishful thinking, named a list in parliament of five military regions that had rallied to the coup. The list proved wrong, but some Spaniards wondered today whether he had some good reasons for issuing it.

The problem that now confronts the new government is how far to push the investigation that hasd already started into the plot. During the brief debate preceding today's vote, the main party leaders were surprisingly moderate in their demands for light to be shed.

The dilemma, as one informed Spaniard put it, is that if the investigation is thorough it could underline what has always been the basic problem of the transition from the 40 years of dictatorship under Franco. This is that the institutions of the new regime, not just the armed forces and the police, were inherited unpurged from the Franco years.

But if a purge is not now conducted, the survivors of the parliament plot might try again, just as the survivors of the comic operetta Operation Galaxy plot of 1978, including Tejero, played prominent roles this week.

If there were to be a next time, any military plotters would be bound to understand the point that they obviously missed this week: that what stands between those who have a nostalgia for military dictatorship and power is not only the 350 members of parliament, but also their own commander in chief, Juan Carlos.

As if to underline the point, the king posed at his palace yesterday standing in the middle of a line of civilian political leaders who had been held hostage in parliament, including Communist Santiago Carrillo, Socialist Felipe Gonzalez, Suarez and conservative Manuel Fraga Iribarne.