A three-man Egyptian military court today resumed the trial, in closed session, of the four Moslem extremists charged with the assassination of president Anwar Sadat and 20 others arraigned as accomplices.

The decision to close the proceedings after two brief public sessions was ostensibly taken to prevent the defendants from using the trial as a forum for their religious and political views or to agitate the nation's fundamentalist minority.

"There is a lot of tension in Egypt, especially in the court," said Ragai Atiya, lawyer for the two chief defendants, Lt. Khalid Ahmed Shawki Islambouli, 24, and Abdel Hamid Abdel Salam Abdel Aal, 29. "This makes it difficult to have a fair trial and they the government are in a hurry."

Another possible reason for closing the trial is the government's desire to contain political controversy over Sadat and his policies and to protect the image of the armed forces.

The official thesis is that the four alleged assassins were part of a vast plot by a secret civilian Moslem extremist faction to kill the entire Egyptian leadership and set up a Khomeini-style Islamic republic.

The government, perhaps to bolster this thesis and minimize the role played by military men in Sadat's slaying, has put on trial together with the four a score of other civilians. They were accused of having helped plot Sadat's killing or being involved in an armed uprising in Assyut two days later.

The four men accused of direct participation in the October assassination are two active military men, one an officer, and two Army reservists. Another military man, Lt. Col. Abdul Latif Zomor, is accused of masterminding the plot.

Thus if the government put only these men on trial now, it could create an impression tending to contradict what the government has already told the nation, that the armed forces were loyal and above suspicion in the affair.

A second problem facing the government is how to hold the trial without giving Islambouli and his associates the opportunity to challenge publicly the official thesis of a vast civilian-led conspiracy.

At their last public appearance before the court Monday, Islambouli and Abdel Aal asserted they only intended to kill Sadat, not the other seven who died in the assault.

Islambouli at first pleaded guilty to killing Sadat but later changed his plea to not guilty like the others.

Islambouli said he told the defense minister, Lt. Gen. Mohammed Abdul Halim Abu Ghazala, during the shooting to get out of the way as he only wanted to get Sadat.

The court has turned down a defense request for testimony from Abu Ghazala and President Hosni Mubarak, who were on either side of Sadat reviewing a military parade when the attack occurred.

The state-controlled media left out of the official transcript published in several newspapers any mention of Islambouli's alleged exchange with Abu Ghazala. But Arab-speaking reporters present at the session, as well as defense lawyers, confirmed that he did make the claim before the three military judges.

Atiya, the lawyer for Islambouli, made clear that the defense wanted to turn the trial into a test of Sadat and his government. He said he would plead "legal common defense" on behalf of his two clients, a term meaning they committed murder on behalf of the Egyptian people because there was no "legal channels" available for ousting Sadat from office.

"The only way to get rid of him was to kill him," said Atiya. "That's what they said during their interrogation."

Atiya said his clients are insisting they did not mean to kill anyone but Sadat and had no grand plan for what to do after his death. He said that while Islambouli would have liked an Islamic republic set up here, he did not have a plan ready and was actually highly critical of Iran's Ayatollah Ruhollah Khomeini because of the mass executions carried out under his rule.

Islambouli's main criticism of Sadat, according to Atiya, was that the late president was "joking" about Islam and Moslem customs like women wearing the veil, which had become a hot issue here just before Sadat's death. Islambouli was also upset about Sadat's crackdown in early September on the Moslem fundamentalist movement and the throwing into jail of a number of popular Mosque preachers.

Atiya contends that a public hearing is very important not only as the best guarantee of a fair trial but also as a kind of national catharsis and warning to present and future Egyptian leaders.

"The whole Egyptian people should know what were the mistakes and faults of Sadat and his public behavior," said Atiya. "In one way or another, we are all responsible for what happened. If there is fanaticism in Egyptian society, it is all our responsibility."

In 1977, Atiya was the lawyer for Shukri Ahmed Mustapha, the founder of the extremist Moslem group Takfir Wa Hijra (Repentance and Holy Flight), which kidnaped and killed a retired religious affairs minister.

Mustapha was convicted and executed, together with four others, for what was the first political kidnaping in Egypt since the 1952 revolution. Atiya said it was a public and fair trial.

He said Islambouli, whom he met for the first time last Saturday, was highly critical of Takfir, which the government first implicated in Sadat's assassination.

Atiya described Islambouli, 24, as a quiet, devoted Moslem, who is very sure of himself and also convinced he is going to his death. "He's not afraid. He thinks he is going to paradise."