Egypt's supreme military court condemned five Moslem extremists to death today for the assassination of the late president Anwar Sadat last October and meted out sentences ranging from life to five years in prison to 17 accomplices.

Winding up a 3 1/2-month trial that was secret and often contentious, the three-man military court convicted and sentenced 22 of the 24 defendants at a hastily arranged public final session inside a heavily guarded Army camp on the outskirts of Cairo.

Two of the accused were acquitted, one a blind sheik, Omar Ahmed Abdel Rahman, whose preachings allegedly helped to inspire the assassins.

The sentences still must be confirmed by President Hosni Mubarak, and the condemned men have 15 days in which to make an appeal to him for mercy. Defense lawyers have asked Mubarak to delay judgment because of alleged irregularities in the court proceedings.

However, most observers here doubt that Mubarak will show much leniency toward the five chief defendants, who were charged with killing Sadat and seven persons with him on a military reviewing stand Oct. 6.

The state-controlled press said today the government was about to indict another 1,000 Moslem extremists arrested after Sadat's killing who belong to the same group, Jihad, to which those convicted reportedly had ties.

This would mark by far the largest trial of Moslem extremists here and it appears to indicate a tough line by Mubarak in dealing with religious fanaticism.

Before the chief judge, Maj. Gen. Samir Fadel Attia, read the verdicts and sentences to a crowd of 150 reporters, a power failure inside the military camp caused the final proceedings to be suspended for two hours. The judges set up a makeshift court in the lobby of the building.

The judges then said the defendants could not be present because they were shouting and making too much trouble, while the 35-man defense team was absent because it had been dismissed by the military judges during Wednesday's session.

Other lawyers were appointed by the court but it could not be determined whether any of them were present for today's final chaotic session. Reporters had been allowed into the main courtroom, where the 24 defendants were locked into four steel-bar cages, shouting slogans and denouncing the court and trial as a sham.

The cages were decorated with banners bearing Islamic sayings, several hangmen's nooses and a single Star of David from which hung a rope, apparently to indicate another noose.

"The blood of the Moslems is not a sacrifice on the alter for the Jews or Americans," cried Lt. Khalid Islambouli, the 24-year-old chief defendant who commanded the truck in the military parade from which he and the three other assassins jumped to attack Sadat.

On one of the banners were the words, "Oh Jerusalem. The caliphate or death. The Moslems are coming."

All of the defendants but one wore long white robes and skullcaps and appeared tense and defiant throughout the 20-minute-long public session allowed to them. All also appeared in good health.

The group included five active or retired Army members and 19 civilians, many of them students. Only one was in uniform, Lt. Col. Abboud Zumur, 35, a member of the Army's intelligence service who was said to have abetted the assassins and to have plotted another attempt on Sadat's life.

Both he and his student brother, Tariq Zumur, were sentenced to life in prison, while Islambouli and the three other participants in the attack--a sergeant and two reserve officers--were condemned to death.

The fifth person to receive a death sentence was Mohammed Abdel Salem Farag, an engineer, who the military prosecution identified as the mastermind of the October assassination plot.

Defendant Mohammed Salamouni read a statement in English: "Sadat made of himself the last pharaoh in our country. He made of himself the last shah. Sadat killed himself by his behavior here in Egypt."

The trial began Nov. 21 with the judges to all appearances determined to see that the proceedings were fair and the defense given all the time it needed to present its case. By the end of December, however, the defense lawyers and court were at loggerheads over the issue of which witnesses would be allowed to appear. The defense wanted to call a number of politicians, including Mubarak and Defense Minister Abdel Halim Abu Ghazala, as well as Jehan Sadat, Anwar Sadat's widow, in what was clearly an attempt to turn tables on the court and put the slain president on trial.

When the court refused to hear most of the requested witnesses, the lawyers resigned and others were appointed. Later the two sides reached a compromise allowing the trial to proceed with the original defense team.

On Wednesday, when the defense sought to have the trial transferred to a civilian tribunal, the military judges dismissed the entire defense team, again named new lawyers, held a last 90-minute session and declared the deliberations over.

The confusion and irregularities surrounding the end of the trial are expected to raise questions at home and abroad about the nature of the proceedings, although there was virtually no doubt that the four chief defendants were the assassins of Sadat and the other seven persons killed in the attack.