A unanimous Supreme Court sharply warned federal judges yesterday not to interfere with college officials who expel students for academic reasons.

But the court, in a narrow ruling by Justice John Paul Stevens, did not shut the courthouse door completely to college students who claim that such dismissals violate their constitutional rights.

The ruling came in the case of a University of Michigan medical student who failed a major test. University officials denied his request to take it again and dismissed him from the school. A federal appeals court said last year that the school violated his constitutional right to due process by denying him a second chance.

Stevens, overturning that decision, said that "when judges are asked to review the substance of a genuinely academic decision . . . they should show great respect for the faculty's professional judgment.

"Plainly, they may not override it unless it is such a substantial departure from accepted academic norms to demonstrate that the person or committee responsible did not actually exercise professional judgment," Stevens said.

Scott Ewing failed his medical boards in 1981, and a university review board twice denied his request for a second chance, although it had routinely allowed all other medical students to retake the exam. The board's decision was supported by a second medical school committee.

Ewing sued, arguing that he had a "property" interest in staying in school, that his dismissal was arbitrary and capricious and that the school had violated his constitutional right to due process.

Stevens cited a ruling that federal courts are inappropriate places to review the "multitude of personnel decisions that are made daily by public agencies." Courts are "far less suited," Stevens said, "to evaluate the substance of the multitude of academic decisions that are made daily by faculty members of public educational institutions."

He said that even if the high court assumes a constitutional right to stay in school, "free from arbitrary state action, the facts . . . disclose no such action."

The record, which Stevens laid out in considerable detail, "unmistakably demonstrates . . . that the faculty's decision was made conscientiously and with careful deliberation, based on an evaluation of the entirety of Ewing's academic career," he said.

Ewing had an "unenviable academic record characterized by low grades, seven incompletes and several terms during which he was on an irregular course load."

Ewing failed five of the seven subjects on the two-day exam, Stevens noted, scoring 235, the lowest mark recorded in the six-year history of the program in which he was enrolled. The passing score was 345. and the national mean is 500.

Ewing told university officials that he deserved a second chance because of personal problems that prevented him from doing better. Stevens said Ewing's mother "had suffered a heart attack about 18 months before the examination; his girlfriend broke up with him about six months before the examination; . . . and his inadequate preparation caused him to panic during the exam."

Stevens concluded that Ewing's academic record was "unfortunate" -- a characterization Justice Lewis F. Powell Jr., in a concurring opinion, said was "charitably" put. "This is a case that never should have been litigated," Powell said.