The Egyptian government appears to have brought under control the most serious threat it has faced in decades, from Moslem extremists who assassinated president Anwar Sadat and allegedly were planning to kill the entire leadership and establish a Khomeini-style Islamic republic here.

But the challenge of the growing Moslem fundamentalist movement in Egypt remains. So, too, do the enormous economic and social problems that have spawned and nurtured it, making long-term forecasts hazardous.

Nearly a month after the trauma of Sadat's assassination at a military parade, Egyptian security forces are still uncovering arms caches and extremist cells scattered across the country, and Egypt's new leader, Hosni Mubarak, still regards internal security as the "main item" on his overcrowded agenda.

Special security forces stand guard, often behind sandbags, in double or triple the previous number at public buildings, embassies, Army and police installations as well as hotels, giving a visitor the impression that the government is not yet at ease.

Yet Mubarak, Defense Minister Abdel Halim Abu Ghazala, and a number of other top officials interviewed here last week seem to feel the crisis is past and the threat posed by what they officially call "terrorists" is receding.

"It is not a big danger," Mubarak said. "Everything is settling down now."

This apparently also is the assessment of the U.S. Embassy, whose officials are citing the smooth transition from Sadat to Mubarak and the prevailing business-as-usual atmosphere as proof of the government's and country's underlying stability.

On the other hand, a top Asian diplomat said he has sent home a report saying that while Mubarak's short-term prospects look good, his medium- and long-term ones appear bleak because of the difficult domestic problems he faces.

In addition, some analysts, Egyptian as well as foreign, harbor grave doubts that the extremists have been more than temporarily cowed and believe it simply is a matter of time before they raise their heads again.

Military and civilian investigations since Sadat's assassination have led to the announced arrest of nearly 650 Moslem extremists and 150 leftists in addition to the roughly 1,600 already in detention as a result of a first crackdown by Sadat in early September.

Details of the alleged conspiracy to attempt another Islamic revolution here, mimicking that of Iran's Ayatollah Ruhollah Khomeini, are still trickling out in the local press as alleged confessions of some of those arrested are published and officials make known more of their findings.

Clearly, much has yet to be revealed, and there are indications that the government is presenting what it knows in such a way as to rally more public support and frighten moderate Moslems -- the vast majority -- as well as Egypt's 6 million Christian Copts. Nonetheless, the main outlines of the plot, and the reasons for its failure, now have emerged -- or at least an official version of them. It is:

The scheme to assassinate Sadat at the Oct. 6 military parade was hatched solely by Lt. Khaled Ahmed Shawqi Islambouli, the commander of an Army artillery unit. Officials described him as a highly frustrated individual who had turned to religious extremism for salvation.

Islambouli belonged to a little-known Moslem extremist group called El Jihad (the holy war), which was first mentioned in the Egyptian press in 1977, when 82 of its members were arrested for stockpiling arms and planning attacks on police stations.

The group surfaced again last January, when some of its members threw bombs into two Coptic churches in the coastal city of Alexandria, killing one terrorist and injuring eight Christans. Seventy more Jihad members were rounded up, including the leader of the bombing operation, Ali Mustafa Magharabi.

He later died of wounds received in an exchange of fire with policemen at the time of his arrest. But press reports at the time said he admitted receiving money and explosives from unnamed Arab countries opposed to Sadat's peace policy toward Israel.

One official interviewed said all the Moslem extremist groups were receiving funds from abroad -- particularly Libya, a bitter opponent of the slain president, but also from Persian Gulf countries.

Abu Ghazala said that that two checks drawn on a bank in Kuwait and thousands of dollars had been seized from Jihad, but added that it was not clear whether it was from sympathizers working abroad (there are 1 million Egyptians in other Arab countries) and sending money back, or from a foreign government.

"There is a possibility of foreign involvement , but we are not that sure and we cannot just put the blame on others," he said in an interview. "It's not right to say it is related to this assassination unless you are sure."

Relatively little is known about the specific objectives of El Jihad other than the government allegations that it sought to wipe out the entire political, military and religious elite and establish a Khomeini-style theocratic state. Its leader, it was learned, has been captured and identified as Mohammed Abdel Salam Farag, an engineer working in Cairo who comes from the Beihaira region southwest of Alexandria.

Abu Ghazala said Jihad shared the same basic ideas as another, better known extremist group, Takfir Wa El Hijra (atonement and holy flight), adding, "They were trying to cooperate with each other."

But Saad Eddin Ibrahim, an Egyptian scholar who has interviewed several extremists in prison, noted at least one fundamental difference between the two: while Takfir considers both state and society hopelessly corrupt and urges its followers to withdraw from both, Jihad believes they can be reformed.

The assassination of Sadat and the attempt to seize power is "not the style of Takfir," he said in an interview. "It wouldn't have been like them to infiltrate the Army."

Jihad, on the other hand, earlier had been found to have police and Army officers "from captain on down," he added.

The government at first spoke only of Takfir as the group behind the assassination, but later it began mentioning an unnamed "terrorist organization," which it said had been recruiting hard-core extremists from other groups and was mainly responsible for Sadat's killing. It is still not clear how many of the 650 extremists arrested since the assassination are members of Takfir and how many of Jihad, or even other groups.

In any case, it does not appear from what is known that either group was planning to assassinate Sadat at the Oct. 6 parade.

According to one high official, Islambouli only went to one section within Jihad on Sept. 26 to tell of his plan to assassinate Sadat in the parade. Those he contacted thought Islambouli was "crazy" and would not succeed, but agreed to provide him with three volunteers to help him anyway, the official said.

Nonetheless, the entire leadership was not alerted to Islambouli's plan and was taken by surprise when he and his three aides not only acted but succeeded.

Abu Ghazala said the military investigation into the assassination had uncovered only eight other active officers and soldiers who were members of the terrorist group in addition to Islambouli.

"We are satisifed that is it," he remarked. "But I can tell you that I am happy there is no kind of organization or group inside the armed forces under the command or control of one single man. They are all related to the civilian group, which is very important for us."

The fact that the entire leadership of Jihad was unaware of what Islambouli was up to explains, officials say, why there was a two-day delay before anything happened after Sadat's assassination. Early Thursday morning, Oct. 8, more than 50 Moslem extremists seized control of the security forces' headquarters in Assyut, 240 miles south of Cairo.

They held out most of the day before abandoning the building and several other police stations and retreating. In all, 53 persons, 44 of them policemen, were killed and more than 100 were injured, according to official figures.

"They failed in Assyut because it was not preplanned," said Abu Ghazala.

The uprising in Assyut was the only major incident after the assassination, although other groups, either from Jihad or Takfir, tried to mount several other operations unsuccessfully.

The general plan, a high official said, was to seize the state television and radio building and other strategic points in Cairo after Sadat's assassination and broadcast appeals to the public to support them in the streets.

"They believed that if they could get rid of the elite in power and create some kind of mess, then they would succeed in having the support of the religious people who were willing to have this kind of Islamic republic model as in Iran," he said.

Just how far Jihad and Takfir had gone in their planning to seize power remains unclear, as does the extent of their attempts to cooperate. But local press reports, based on confessions and official statements, said they had already assigned 50 persons to take over the main radio and television building and named the leader as Sayed Rashad, an engineer.

Others have said there were plans to assassinate other Egyptian leaders during Sadat's funeral procession, and this is what forced a last-minute change in its route. There also were reports of planned attacks on Mubarak during the ceremony swearing him in.

All this suggests that the Moslem extremists were far closer to mobilizing than the government is willing to admit publicly. One of the most difficult questions to answer today is how much the government really does know about Jihad, Takfir and other such groups and the extent of their infiltration into the government and, more importantly, the armed forces.

Many analysts, including Ibrahim, doubt that there were only nine officers and soldiers involved in extremist organizations in an Army of nearly 400,000 men.

The Army has also announced that another 134 officers and soldiers have been dismissed as security risks because of their extremist religious views. But even this number seems small, as does the total number of Moslem extremists reportedly arrested since early September -- about 1,450 of the roughly 2,400 official total of detainees.

All this raises the disturbing question of whether the Egyptian government and its various security and intelligence units are as much on top of the situation as Mubarak and others claim. They apparently were not aware of the extent of El Jihad's penetration until after Sadat's assassination.

For the moment it appears that Egypt is settling down. But how long it will stay calm is difficult to predict.