The unrelenting wave of terrorist killings in Spain has aroused strong sentiment against this country's fragile democracy among a number of military officers who are openly defying not only the government but King Juan Carlos, their commander-in-chief.

The king's sharp rebuke of officers a week ago for turning the funeral of an assassinated general into a fascist demonstration has done little to cool "emotional dissent" in officer's mess halls, according to informed military sources.

The anger is such, sources said, that the king's portrait has either been removed or turned face against the wall in important barracks. Western analysts confirmed that "griping is unquestionably hot" in many garrisons, but they discounted the possibility of a coup.

The temper of the officer corps can be measured by the resignation Friday of a national police general and two colonels who disagreed with the government's "soft" plan for combating urban guerrillas. So far this year, guerrillas have killed 10 persons, including Madrid's military governor, a Supreme Court judge, and several police officers.

Seven were slain by ETA, which is fighting for the independence of the Basque provinces.

Spain's major public order forces -- the heavily-armed national police, the paramilitary Civil Guard and the plainclothesmen of the Security Directorate -- are under the command of regular army officers.

Saturday, the government ordered 2,000 national police to the Basque region to reinforce large contingents already there, and police clashed with demonstrators in the Basque city San Sebastian today.

Like the Spanish Army, the security forces were trained and deployed by the late dictator Francisco Franco to fight "terrorist enemies" under 1936-39 civil war regulations that were abrogated by the democratic constitution approved in a referendum last month.

Nevertheless, rightist army generals, colonels and majors publicly insult the defense minister, retired Lt. Gen. Manuel Gutierrez Mellado, and blame him for doing nothing while "terrorists kill officers and police with impunity."

The defense minister is backed by the king, the premier and loyalist officers, but his project to cut the number of civil war veterans in the armed forces by lowering the retirement age to 55 has been shelved for months. The reason: fear of a rightist back lash.

Another target of military criticism is Premier Adolfo Suarez, who, with the king's full backing, has master minded the difficult transition to democracy and called parliamentary elections for next March 1.

Last November the premier survived an attempted military coup that the government has minimized. Extensive talks with loyalist military officers and Spanish officials indicate it was a serious plot that involved plans to kill the premier and two other Cabinet officers.

Some high officers, who have strong support within the conservative navy, make no secret of their objectives. They want the king to impose martial law in the Basque region to "liquidate ETA once and for all."

The king and the government so far have resisted military pressure for the "pacification of the Basques." But some Spanish officials believe that if ETA, an acronym for Basque Independence and Liberty, continues its terrorist campaign, a junta of senior military officers is prepared to go to the king to demand postponement of parliamentary and municipal elections and appointment of a rightist civilian gobernment that will cooperate with the military and give the army a free hand to deal with ETA.

Western diplomats, who had assumed that the military had been tamed by the king, have been distressed by the mounting signs of military discontent.

"Any strong army move would end Spanish expectations of entering the Common Market and of joining the North Atlantic Treaty [Organization]," said a diplomat. "But the behavor of the military in the past two months shows the frailty of Spanish democracy."

Neither NATO nor the Common market appear to matter to rightist officers.

"We survived without them before," said a colonel. "We'll get along without them in the future. What matters to us is terrorism, our dead, and the unity of Spain. We can't let ETA dismember Spain to please countries that don't really like us, anyway."