The Supreme Court, reaffirming a constitutional "right of access" to trials, ruled yesterday that states may not automatically exclude the press and public from criminal trials, even to protect young sex crime victims from public humiliation.

The court said that while judges may close trials involving minor victims of rapes in exceptional circumstances on a case-by-case basis, blanket exclusions violate First Amendment free speech guarantees.

In an angry dissent, Chief Justice Warren E. Burger said the majority's decision will be used to make minors recount sexual assault details in front of "voyeuristic strangers" and, in some states, television cameras "with reruns on the evening news. That ordeal could be difficult for an adult," he said. "To a child, the experience can be devastating and leave permanent scars."

The "disturbing paradox of the case," he said, is that minors accused of committing such crimes are protected from public embarrassment by laws putting juvenile proceedings behind closed doors. Justice William H. Rehnquist joined Burger in the dissent. Justice John Paul Stevens, writing separately, also dissented.

The 6-to-3 decision, written by Justice William J. Brennan Jr., struck down a Massachusetts law mandating closure of sexual offense trials involving a victim under the age of 18.

The law was challenged by The Boston Globe, after being barred from the trial of a 33-year-tennis pro charged with raping three teen-age girls, two 16 and one 17. Neither the girls, the prosecutors nor the defendant wanted the trial closed. The Massachusetts high court upheld the law, but limited the exclusions to times when the minors were actually testifying.

Yesterday's opinion was an elaboration on the court's 1980 landmark decision declaring a constitutional right of access to trials, which could extend to other traditionally open governmental proceedings. That decision, in Richmond Newspapers Inc. vs. Virginia, mandated openness for trials except in "overriding" circumstances. But it did not specify what those circumstances were and how they were to be determined.

Only one law--the Massachusetts statute at issue yesterday--imposed a flat ban on attendance at sex crime trials involving minors. The case was being watched by news organizations, lawyers and judges for any broader guidance it might provide on trial openness, however.

Brennan said yesterday that only a "compelling governmental interest"--an overwhelming need--justifies closure of any trial. That need can only be determined by examining the situation in each case, he said. Sweeping mandatory closure laws do not allow that examination, he said.

He rejected one Massachusetts justification for the law--that it encourages victims to come forward and testify--as speculative and perhaps untrue. The other stated purpose, to protect minor victims from further trauma and embarrassment, is a "compelling one," Brennan said.

"But as compelling as that interest is," he said, its validity can only be weighed by looking at the factors involved in each individual case, such as "the victim's age, psychological maturity and understanding, the nature of the crime, the desires of the victim, and the interests of parents and relatives."

Had those factors been examined in the case considered yesterday, Brennan said, closure might have been unnecessary. The victims, the supposed beneficiaries of the closure, were not seeking exclusion, he said.

Justice Sandra Day O'Connor broke with her allies, Burger and Rehnquist, in Globe Newspaper Co. vs. Superior Court for the County of Norfolk. But in a concurrence separating herself from the broad wording of Brennan's opinion, she emphasized that the decision applied only to criminal trials. Stevens, in his separate dissent, said he thought the 1978 case was moot.

Press interests applauded the ruling. "It is very encouraging," said Jack Landau, of the Reporters Committee for Freedom of the Press. "It creates a very heavy presumption of openness."

Bruce W. Sanford, attorney for the Society of Professional Journalists, Sigma Delta Chi, called the decision "thoroughly unsurprising" after the Richmond case, noting that the press should be prepared to argue closure orders on a case-by-case basis.

In another decision yesterday, the court ruled that the confession of an Alabama robbery defendant must be thrown out because his arrest, preceding the confession, was illegal.

Justice Thurgood Marshall, writing for the 5-to-4 court, said the confession would not have been made but for the arrest. Therefore, the illegal arrest taints the otherwise valid confession.

Dissenting Justice O'Connor, joined by Burger, Rehnquist and Lewis F. Powell Jr., said Marshall distorted the facts and the law to reach his result.