To the Egyptian military command, the assassination of president Anwar Sadat by one of its lieutenants last week was a shock and embarrassment unrivaled since their ignominious defeat by Israel in 1967.

A greater trauma, foreign analysts here say, may prove to be the realization by the Egyptian military leaders that they have lost touch with the vast military establishment they preside over -- an establishment that is the cornerstone of Egyptian society.

Western military observers in close contact with Egypt's command say Sadat's assassination was such a surprise to the Egyptians because it was led by a lieutenant in a military force that its commanders believed could harbor no dangerous dissidents, much less a presidential assassin.

Sadat had given the military a clean bill of health only a month ago, after his mass crackdown on 1,536 dissidents, more than two-thirds of them leaders or activists in the fundamentalist Islamic societies. There were reports that a small number of military men had also been arrested but there has been no confirmation.

"The reason Sadat's assassination came as such a surprise to us was, up to this time, we had been told that his crackdown had found very few suspects in the Army," said one military observer in contact with Egypt's high command. "We were told that they had cleaned out the dangerous Islamic factions from the military. Apparently the measures were not enough."

Some knowledgeable Western diplomats speculate that Sadat was convinced by military intelligence that there was no problem at all in the military or that the problem was so small it could be ignored out of traditional reluctance to admit dissent in Egypt's proud armed forces.

Western military attaches and diplomats who specialize in analyzing Egypt's military always have felt that their knowledge of internal currents within the armed forces was limited by their isolation from all but those officers authorized to talk to them. Nevertheless, their assumption was that the Egyptian command on whom they relied for information knew their forces thoroughly.

Such assumptions are no longer accepted among analysts here who fear that the senior-officer class of Egypt's military establishment -- from which both Sadat and his successor, Hosni Mubarak, came -- may have lost touch with the mood of its ranks and junior officers.

Egypt's high command, and Sadat himself, never ceased to praise the loyalty of the Army and point to its discipline and apolitical nature.

Even when it became evident that dissidence was growing in the country at large, with mushrooming societies of Moslem fundamentalist extremists that considered Sadat a traitor to Allah because of the secularism of his government and its acceptance of peace with Israel, the military establishment remained certain that such notions posed no real threat within the armed forces.

The assassination last week, however, has made the problem within the military evident. The only thing not known today is just how large it is. "Frankly, at the moment, we just don't know enough about the magnitude of the problem," said one Western diplomat with strong military ties. The armed forces "have a problem all right, but the question is how big a problem is it? I don't think the Egyptians themselves know either."

The official allegation that Lt. Khaled Shawki Islambouli, as ringleader of a four-man group that shot Sadat at a military parade last week, was linked to an Islamic extremist group has brought home that the problem exists.

Evidence that in the past week up to 200 other military men have been cashiered from the service for their religious views, in what has all the earmarks of a purge, is proof that the problem has shaken the military's traditional confidence in the loyalty of its officers and troops.

"Officially we are being told that the number of fundamentalist extremists in the military is minimal; at the same time we are hearing from other quarters that the military is riddled with extremists," said a Western diplomat who specializes in the Egyptian military.

What makes the issue so vital to Egypt's stability is the fact that the 367,000-member armed forces, the biggest in the Middle East and North Africa, are the dominant governing and social force in the nation.

Ever since Gamal Abdel Nasser and his Free Officers movement overthrew the monarchy of King Farouk in 1952, the Egyptian military has run the nation.

Aside from the presidents, Cabinet ministers, directors of government departments, and thousands of lesser officials that the armed forces have provided to run Egypt, the military in the last three decades has become a state within a state, the nation's largest employer and its most efficient welfare system, with a network of its own industries, public works corporations and farms.

The military has become the true elite of Egypt and on its unity and stability the immediate future of the nation depends.

Since Egypt's embarrassing defeat by Israel in 1967, the armed forces have been reorganized. In the professional Army, discipline, obedience and loyalty to the state are supposed to have elevated its members beyond the political, social and religious rivalries of the civilian world from which they came.

The new sense of pride in the martial establishment forged in the past 14 years has given today's military leaders confidence. This has made them ill-disposed to countenance any suggestion that there can be dissidents within the armed forces. When dissent has cropped up in the military ranks, it has been downplayed.

As Mubarak put it in his inaugural speech, trying to reassure the nation and armed forces, "Don't let one traitor in your history tarnish your greatness. This will be forgotten in the most glorious chapters of history still to be written."

The reconstruction of Egypt's armed forces since 1967 has taken place as Egypt's society moved toward a revival of Islam as a substitute for secular experiments in parliamentary liberalism and Nasser's pan-Arab socialism, whose failure was embodied in the 1967 defeat.

Across the country, from the poorest village to the middle-class urban universities, about 12,000 Islamic societies have flowered in this period, pressing the message on future privates and officers that traditional Islam offers the strength and purity to restore modern Egypt to its past glories.

No one knows how many of those who believed in the fanatical traditions of the Moslem Brotherhood entered the Army, through military academies or the national compulsory service.

The question raised constantly now is, where does the Egyptian military make the distinction between a pious officer who does not drink and prays devoutly at a mosque and the extremist plotting attacks on a government he thinks is going against the teachings of Allah?

The military's failure to perceive the extent of the extremist problem was made clear this week by Defense Minister Abdel Halim Abu Ghazala, who disclosed that before Sadat's killing the civilian state security service had alerted the military to Islambouli's suspected extremism.

Ghazala said military intelligence put Islambouli under observation but cleared him. Although his brother had been arrested in September for being a member of the most militant Islamic group, military intelligence said the young lieutenant "was known for his loyalty and discipline."

"If the military intelligence could not spot someone like Islambouli who had actually been fingered by the state security service," one Egyptian journalist asked, "how can they find others like him who are sure to be in the military, too?"