The Supreme Court held yesterday for the first time that the public and press have a constitutional right to witness criminal trials, but said the proceedings may be closed in rare, unspecified circumstances.

Ruling in the case of a Virginia judge who closed a 1978 murder trial to reporters and spectators, the court held that "absent an overriding interest" to the country, "the trial of a criminal case must be open to the public."

Chief Justice Warren E. Burger wrote that such a right is "implicit in the guarantees of the First Amendment."

The court's decision was 7 to 1, with Justice William H. Rehnquist dissenting. Six of the justices agreed that there is a First Amendment guarantee to open trials, and a seventh said it is a Sixth Amendment right. But all of them, including Rehnquest, clearly believe that right is not absolute.

Under a Supreme Court ruling last year, it appeared that the right to an open trial was guaranteed only to the defendant, who could have it closed if prosecutors did not object. Yesterday's ruling also gives the public and the press a clear voice in any decision to close a trial.

Despite limitations, the decision -- one of the biggest involving press freedom since the Pentagon Papers case of 1971 -- was hailed yesterday by press representatives across the country.

"No criminal trial has been closed to the public in the history of our country prior to this case and I trust this will mark the end of this worrisome chapter in our judicial history," said Washington Post board chairman Katharine Graham, speaking as president of the American Newspaper Publishers Association.

"Every American can be delighted" by the decision. Graham added.

The publisher of the Richmond newspapers, which brought the appeal after two of their reporters were expelled from a Hanover County courtroom two years ago, said the ruling upholds "the right of the American people to see their system of justice in action."

Publisher J. Stewart Bryan III added that the ruling was "a victory for the American people, and only secondarily for the American press and even less for the Richmond newspapers."

The judge whose decision was reversed, Circuit Court Judge Richard H. C. (Dickie) Taylor, reacted by defending his original action, but adding "If the situation comes up again, I might have a different decision."

Taylor had invoked a Virginia law that says a trial court "may, in its discretion, exclude from the trial any person whose presence would impair the conduct of a fair trial. . . ."

The Supreme Court did not rule on the constituionality of that law yesterday, although Justices William J. Brennan Jr. and Thurgood Marshall, in a separate opinion, found that the Virginia code "violates the First and Fourteenth amendments."

The Burger opinion faulted Judge Taylor for offering "no findings to support closure."

Secret criminal trials were virtually unheard of in this country until the Burger court ruled a year ago that a pretrial hearing on the suppression of evidence could be closed. Since that ruling last July 2, in which the court rejected an appeal brought by the Gannett newspaper, court watchers have recorded more than 260 instances of judges closing parts or all of criminal proceedings.

The decision does not apply to pretrial proceedings, which now appear goverened by last year's Gannett ruling saying they could be closed much more easily.

In addition, civil trials are not necessarily covered, though a footnote suggested they might be.

Yesterday's decision (in which Justice Lewis F. Powell, who is from Richmond, did not participate) was far from clear-cut in offering guidance to trial court judges about when, if ever, they could close their courtrooms.

The decision included seven separate opinions, and not all the justices agreed on the approach to or reach of the constitutional issues.

Justice John Paul Stevens called Richmond Newspapers Inc. vs. the Commonwealth of Virginia "a watershed case."

Stevens said the court earlier had "accorded virtually absolute protection to the dissemination of information or ideas, but never before has it squarely held that the acquisition of newsworthy matter is entittled to any constitutional protection whatsoever."

Before yesterday, press victories had come in the clearer constitutional area of censorhip. Those rulings, such as in the Pentagon Papers action, held that judges may not restrain the media from disseminating the news once it was gathered.

But on question about news gathering, the media have fared much worse. The court has ruled that reporters do not have a right to withhold confidential sources from a grand jury; libel plaintiffs may inquire as to the "state of mind" of reporters and editors; and police may search newsrooms for evidence of a crime without securing a subpoena.

While the friction between the constitutional principles at odds in the Richmond case -- the public's right to know versus a defendant's right to a fair trial -- are as old as the republic, the confrontations have intensified in the last decade.

Judges and lawyers have increasingly argued that the media are seeking special privileges, well beyond those guaranteed by the First Amendment. The press has countered that any action impeding news gathering or reporting "chills" press freedom.

In the Richmond case, the press also contended that the Constitution meant to guarantee open trials, not just to its immediate participants, but to the public at large, and on that, the Supreme Court concurred overwhelmingly yesterday.

Chief Justice Burger, who has been portrayed as a villain by many in the press, spoke forcefully, in his 24-page opinion, about the need for open trials.

Early American jurists, including many in Virginia, Burger noted wryly, "saw the importance of openness to the proper functioning of a trial; it gave assurance that the proceedings were conducted fairly to all concerned, and it discouraged perjury, the misconduct of participants and decisions based on secret bias or partiality."

It is not enough, Burger wrote, for justice to be carried out. The process must also "satisfy the appearance of justice," he wrote, quoting an earlier court. "The appearance of justice," Burger added, "can best be provided by allowing people to observe it."

Burger noted that most people no longer "pass the time" by sitting in courtrooms, as many did in colonial America. They now acquire information about trials "chiefly through the print and electronic media. In a sense, this validates the media claim of functioning as surrogates for the public," the chief justice said.

In the lone dissent, Rehnquist said he did not believe a state court closure decision, agreed to by both the prosecutor and the defendant, should be "subject to any additional constitutional review at our hands." The issue, as Rehnquist saw it, was "whether any provision in the Constitution may fairly be read to prohibit what the trial judge in the Virginia state court system did in this case." Rehnquist concluded none does.

Taylor's decision to close the trial, announced June 6, 1978, after a casual, uncontested courtroom exchange with the prosecutor and a defense lawyer who suggested it, came in a murder trial in which a drifter was charged with robbing and fatally stabbing Lillian Keller, a 55-year-old motel clerk.

Although the case was so routine that the local weekly newspaper in Hanover County did not bother to attend the trial, the two Richmond papers sent reporters. After the judge evicted the reporters, a lawyer for the newspaper protested the decision, but it was upheld by the Virginia Supreme Court on July 9, 1979 -- a week after the Gannett ruling by the U.S. Supreme Court.

Virginia Attorney General J. Marshall Coleman, who defended the Virginia position before the Supreme Court, said that because the court ruled that the right to open trials is not absolute, "the essence of this case remains unresolved. . . . My concern in this case was that in the rush to shore up the rights for the press and the public we not neglect the right to a fair trail."

The outcome of the trial at issue is moot, because less than a day into the secret trial, at the end of the prosecution's case, Judge Taylor, accepting a defense motion, dismissed the jury and announced a finding of not quilty.

But the Supreme Court did not find the issue moot, because, as Chief Justice Burger put, it "the underlying dispute is 'capable of repetition.'"

One of the defenses offered by Virginia Attorney General Coleman was that a recorded transcript of the trial assured the public a chance to find out what happened at the trial.

Justices Brennan and Marshall disagreed, saying a transcript is "no substitute for a public presence at the trial itself." Also, they said, "the 'cold' record of a transcript is a very imperfect reproduction of events that transpire in the courtroom."

In the Virginia Trial the proceeding was recorded electronically, but the stenographer who owns the taped transcript has never put it on paper. She has allowed several attorneys and newspaper reporters to listen to it for $60 each. But the family of the victim has never heard or read the details of why the man charged with the murder of Lillian Keller was turned loose after a short, secret trial.