The Supreme Court ruled unanimously yesterday that the presence of armed, uniformed guards at a trial does not necessarily violate a defendant's constitutional right to a fair trial.

A federal appeals court overturned the conviction of a Rhode Island robbery suspect because four uniformed state troopers had been seated directly behind him during the trial. The appeals court ruled that the presence of so many officers would lead jurors to believe the defendant was guilty.

Justice Thurgood Marshall, writing the opinion in Holbrook v. Flynn, said use of uniformed troopers in this case was not so "inherently prejudicial" to the defendant's right to be presumed innocent.

"We do not minimize the threat that a roomful of uniformed and armed policemen might pose to a defendant's chances of receiving a fair trial," Marshall said. "But we simply cannot find an unacceptable risk of prejudice in . . . four such officers quietly sitting in the first row of a courtroom's spectator section."

In some cases, Marshall said, use of a great number of officers might "create the impression in the minds of the jury that the defendant is dangerous or untrustworthy."

He noted that the court has required that defendants not appear in prison clothing when on trial in order not to prejudice the jury. But "this does not mean, however, that every practice tending to single out the accused from everyone else in the courtroom must be struck down," he said.

The issues must be reviewed case by case, he said.

Jurors in some cases "may just as easily believe that the officers are there to guard against disruptions emanating from outside the courtroom or to ensure that tense courtroom exchanges do not erupt into violence," Marshall said.

In this case, he said, Rhode Island had a legitimate reason to ensure that the defendant, tried with five alleged accomplices, did not escape.