A bitterly divided Supreme Court ruled yesterday that presidents may not be sued for monetary damages even if they break the law or violate citizens' constitutional rights.

The 5-to-4 decision, sought by former president Richard M. Nixon after being sued by one-time Pentagon cost analyst A. Ernest Fitzgerald, created an absolute presidential immunity from civil damages suits and, the majority said, from the inhibiting and time-consuming results of the thousands of such suits that could be brought against a chief executive.

The court refused to similarly shield top aides to the president, ruling in a complaint brought by Fitzgerald against Nixon aides Bryce N. Harlow and Alexander P. Butterfield.

Justice Byron R. White, writing the dissent on the Nixon ruling, called Justice Lewis F. Powell Jr.'s majority opinion on presidential immunity "tragic." It "is a reversion to the old notion that the king can do no wrong," he said. It "places the president above the law." Justices William J. Brennan Jr., Thurgood Marshall and Harry A. Blackmun joined White in dissent.

In the course of ruling on the two complaints yesterday, the court made another major change in laws designed to deter official misconduct: the justices, apparently in reaction to thousands of damages claims now swamping state, local and federal officials as well as police officers, gave judges new authority to weed out frivolous or insubstantial suits without requiring lengthy and costly trials.

Trials will be permitted only where a judge agrees that a "clearly established" breach of a law or constitutional right is involved, the court said in an 8-to-1 vote on Harlow vs. Fitzgerald.

Fitzgerald was the analyst with the Air Force who drew national attention as "the Pentagon whistle blower" when he testified before a Senate subcommittee in 1968 concerning $2 billion in cost overruns and unexpected technical difficulties on the C5A transport plane.

The Nixon administration eliminated Fitzgerald's job in 1970, claiming his removal was only part of an Air Force reorganization. At a 1973 news conference, Nixon took personal credit for Fitzgerald's dismissal: "It was a decision that was submitted to me," the president said on Jan. 31, 1973. "I made it and I stick by it."

Nixon later retracted the comment. But Fitzgerald sued him for damages in 1978 for violating his free speech rights, adding the former president as a defendant to the suit he had already brought against the two Nixon White House aides he said participated in the decision, Butterfield and Harlow.

Nixon claimed total immunity as president from such suits. Harlow and Butterfield claimed that they shared that immunity. The U.S. Court of Appeals for the District of Columbia rejected all the claims, just as it had earlier in a suit brought against Nixon, Henry A. Kissinger and others by former National Security Council staffer Morton Halperin.

The immunity granted by the court yesterday extends to all "official" acts of the president. But Powell disputed the contention that he was placing the president "above the law," saying that there are still adequate deterrents to presidential misconduct, including impeachment. He noted that, as in the Watergate tapes case, the president could be subjected to subpoenas, to "constant scrutiny by the press" and to "vigilant oversight" by Congress.

At the same time, he said the Constitution, in its separation of powers provisions, requires that the chief executive be allowed to exercise his powers. "The president's unique status under the Constitution distinguishes him from other executive officials," Powell said. "Because of the singular importance of the president's duties, diversion of his energies by concern with private lawsuits would raise unique risks to the effective functioning of government."

The chief executive now joins a select group of officials immunized by the Supreme Court, including Supreme Court justices, other judges and prosecutors. The Constitution explicitly protects members of Congress from having to answer in the courts for official decisions. Presidential immunity, under Powell's ruling, appeared to be even broader than theirs, reaching, as he put it, to "the outer perimeter" of the presidency.

The court has extended much less protection to all other public officials ranging from Cabinet officers to police officers to dog catchers. They may not be sued for actions taken in "good faith."

In ruling on the Harlow and Butterfield case, the court said they and other top presidential aides ordinarily enjoy only that same "good faith" immunity that protects the other officials.

Except in special circumstances, perhaps involving foreign policy or national security decisions and where they function as "alter egos" of the president, these top-level White House assistants should be treated like Cabinet members, Powell said.

But in an important victory for these aides and holders of public office everywhere, the court radically altered the definition of "good faith." In the past, they lost their protection if they acted "with malicious intention" to break a law or violate a citizen's rights. Powell said that was too subjective and often resulted in trials or lengthy and expensive fact-gathering expeditions just to resolve the immunity issue.

Yesterday, the court said they could be sued only when the law or constitutional safeguard breached "was clearly established at the time an action occurred."

If not, Powell said the judge should dismiss the case without a trial. He said this frees officials from harassment through frivolous or insubstantial suits: "The social costs include expenses of litigation, the diversion of official energy from pressing public issues, and the deterrence of able citizens from acceptance of public office."

Chief Justice Warren E. Burger dissented in Harlow vs. Fitzgerald, saying that presidential aides should share presidential immunity, as Capitol Hill aides are sometimes allowed under court rulings to share legislative immunity.

Justices Brennan, Marshall, Blackmun, White and William H. Rehnquist joined in separate statements, but with John Paul Stevens and Sandra Day O'Connor, also agreed with Powell's majority opinion.

In Nixon vs. Fitzgerald, the absolute-immunity decision, Blackmun, joined by Brennan and Marshall, wrote a dissent in addition to White's.

The court attempted unsuccessfully to resolve these same questions last year in Halperin's case. It resulted in a 4-to-4 split, when Rehnquist disqualified himself because he had been a member of the Nixon Justice Department. That case is still in the U.S. District Court in Washington, awaiting yesterday's ruling for further action.

Some justices thought the issue should have been left unresolved again this term, because of an out-of-court settlement between Nixon and Fitzgerald. Under that agreement Nixon agreed to pay $142,000 to Fitzgerald in exchange for the dropping of the suit. Nixon agreed to pay Fitzgerald another $28,000 should Fitzgerald win the immunity issue at the Supreme Court. Thus, no matter how the court ruled yesterday, there would be no trial of Nixon under the agreement.

Blackmun, with Brennan and Marshall, called this a "wager" yesterday, which, they said, made the case inappropriate for review.

Fitzgerald, who won a separate legal battle for reinstatement on June 15, said yesterday that the immunity decision "ought to frighten anyone who loves liberty. If the king can do no wrong, we're in a lot of trouble." His suit against Harlow and Butterfield goes back to the District Court for further consideration.

Arthur Spitzer, an American Civil Liberties Union official here, said the decision "puts the president above the law."

A Nixon lawyer, R. Stan Mortenson, praised the ruling, saying that the presidency should have the same immunity enjoyed by the top officials in the other branches of government.

Elliot L. Richardson, representing Harlow and Butterfield, applauded the ruling in his clients' case and said "public officials from local school board members to White House advisers and the public itself" should also applaud it. 4130:Picture, A. ERNEST FITZGERALD . . calls immunity decision frightening.