The Supreme Court agreed yesterday to decide whether a judge can eject the press and public from a pretrial criminal proceeding on the basis simply of a claim that a defendant's right to a fair trial is in danger.

The justices will hear argument in the term starting in October in a case brought by Gannett Co. Inc., one of the nation's largest newspaper chains, which operates two newspapers and a television station in Rochester, N.Y.

In Washington, the Reporters Committee for Freedom of the Press said that, because 89 percent of all indictments are settled in pretrial proceedings, the case is extremely important.

The case goes back to 1976, when Judge Daniel A. DePasquale of Seneca County, N.Y., began a hearing on whether to suppress certain evidence involving two men indicted in the apparent slaying of a policeman, Wayne Clapp, whose body never has been found.

Defense attorneys moved to close the hearing on the ground that the evidence to be discussed "may or may not be brought forth subsequently at trial." The prosecutor agreed. The judge then closed the hearing, ordering out a Gannett reporter.

DePasquale rejected the reporter's written request to delay the closure until her employer had a chance to argue against it, and the company sued.

An intermediate appellate court held that the exclusion violated the public's "vital interest in open judicial proceedings" and was a prior restraint on publication in violation of the First Amendment to the Constitution.

But the state's highest court overturned the decision by a 4 to 2 vote.

"To allow public disclosure of potentially tainted evidence, which the trial court has the constitutional obligation to exclude, is to involve the court itself in illegality," the opinion for the New York Court of Appeals majority said.

"At the point where press commentary on [pretrial] hearings would threaten the impaneling of a constitutionally impartial jury, pretrial evidentiary hearings are presumptively closed to the public, including the press," the majority said.

"To safeguard the integrity of its process, the court was required at the outset to distinguish mere curiosity from legitimate public interest," the majority added.

The opinion for the dissenters said that DePasquale had invoked the "drastic remedy" of closure "without notice, without hearing, and without substantiation of a clear and present state necessity . . ."

Saying that "the necessity for public inspection is not diminished because the proceeding is a pretrial hearing to suppress evidence," Judge Lawrence H. Cooke went on:

"The guidelines expressed by the majority signal the common, if not certain, locking of the courtroom door virtually whenever requested in pretrial hearings . . .

"Our greater concern is that the majority has turned the burden of proof around . . . instead of demanding a heavy burden of showing that alternatives to closure cannot insure a fair trial," the majority "requires a determination of the 'magnitude of any genuine public interest.'

"This presumes that the press should be excluded and discourages use of alternatives to closing the courtroom. In effect, this procedure suggests that any pretrial publicity automatically produces an unfair trial - a proposition expressly rejected by the Supreme Court . . ."

The Supreme Court took other actions: DISARRAY IN APPEALS COURT

The Supreme Court refused 7 to 2 to end a disarray in lower courts over a basic question of criminal justice: when is a defense lawyer's performance so poor as to deny an indigent client the effective assistance of counsel guaranteed by the Constitution.?

The majority gave no reason for not trying to eliminate disparities in the allowable minimum quality of representation. In a sharp dissent, Justice Byron R. White, joined by Justice William H. Rehnquist, wrote:

"In refusing to review a case which so clearly frames an issue that has divided" the 11 U.S. courts of appeals, "the court shirks its central responsibility as the court of last resort, particularly its function in the administration of criminal justice . . ."

Three of the circuits, the 1st, 2d and 10th, hold that representation of a defendant will be deemed adequate under the Sixth Amendment unless it made "a mockery, a sham or a farce of the trial."

The 4th Circuit (Maryland, Carolinas, Virginia and West Virginia) imposed the "farce" standard starting in 1965, but has acknowledged that it "implicitly departed" from it starting in 1968.

Last September, ruling in a Baltimore County sexual assault case, the appeals court expressly disavowed the standard.

"Our ambivalence has persisted long enough," Judge John D. Butzner Jr. wrote.

With that, the court adopted a standard said by the Supreme Court in 1970 to be proper: a defense counsel's advice must be "within the range of competence demanded of attorneys in criminal cases."

The "reasonably competent" standard, or something like it, also is in effect in the District of Columbia and in the 3d, 5th, 6th, 7th and 8th circuits. The 9th is internally divided.

White and Rehnquist needed two more votes to win review of the Baltimore County case, which involved the 1974 trial of Victor D. Marzullo. He was indicted on one indictment for assault with intent to rape, and another for perverted practice.

The public defender's office appointed a lawyer to represent him. Marzullo complained to the judge, "I really don't think for one minute he is going to try and defend me adequartely . . ."

A jury convicted him. He drew concurrent sentences of 10 years and five years.

Marzullo sought relief first in the state courts and then in the federal courts. The 4th Circuit held that his representation was indequate because his lawyer took "a perfunctory approach to the important task of selecting an unbiased jury." Marzullo now will go free or be retried. SPEEDY TRIAL

The court voted 8 to 0 to reinstate the 1975 indictment of Dr. Jeffrey R. MacDonald, a former Army medical captain, charging him with the murder five years earlier of his pregnant wife and two small daughters at Fort Bragg, N.C. Because he had moved before trial to appeal denial of his motion to dismiss the indictment, his right to a speedy trial had not been violated, Justice Harry A. Blackmun wrote. SLAVERY

The court let stand the conviction of three men for inflicting involuntary servitude on employes they hired to harvest fruit in florida and North Carolina. The men used beatings, terror and pay practices that left employes in their debt for necessities. The men are Ivory Lee Wilson and his brother, Roscoe, each of whom drew three years, and William J. Bibbs, 18 months. WOMEN JURORS

The court agreed to review a provision of the Missouri constitution that allows women, solely on the basic of their sex, to elect not to serve as trial jurors.