The Supreme Court ruled yesterday that Cabinet members and other high government officials do not have total immunity from lawsuits for illegal conduct -- even when they act to protect national security.

But the court, in a 13-year-old case involving former attorney general John N. Mitchell, said Mitchell was entitled to partial immunity and need not stand trial on a lawsuit for approving warrantless wiretaps in 1970, because those actions were not clearly illegal at the time.

The court, departing from recent decisions deferring to executive branch claims of national security, rejected the Reagan administration's arguments that Mitchell and other top officials are entitled to absolute protection from lawsuits involving actions they take in that area.

''The label of 'national security' may cover a multitude of sins,'' Justice Byron R. White wrote for the majority in Mitchell v. Forsyth. ''The danger that high federal officials will disregard constitutional rights in their zeal to protect the national security is sufficiently real to counsel against affording such officials an absolute immunity.''

Members of Congress, judges, prosecutors and the president have been given total immunity from lawsuits for their official actions. Other top federal officials, such as Cabinet officers, have been given a more limited immunity that shields them from lawsuits except where they act in willful disregard of the law.

The court, with seven justices participating and with shifting majorities on the various issues, gave the administration an important victory on one aspect by ensuring that top officials with limited immunity will not face frivolous lawsuits.

A majority said an appeals court may step in immediately to review any judge's ruling that allows a top official to be sued.

In the ruling, White wrote that the attorney general ''will be entitled to immunity so long as his actions do not violate clearly established statutory or constitutional rights of which a reasonable person would have known.''

White said he recognized that ''this standard will not allow the attorney general to carry out his national security functions wholly free from concern for his personal liability; he may on occasion have to pause to consider whether a proposed course of action can be square with the Constitution and the laws of the United States.''But that is ''precisely the point'' of the court's prior decisions in this area, White said, quoting a 1982 opinion: ''Where an official could be expected to know that his conduct would violate statutory or constitutional rights, he should be made to hesitate.''

White said the government's argument was the national security functions of the attorney general ''were so sensitive, so vital to the protection of our nation's well-being, that we cannot tolerate any risk that in performing those functions he will be chilled by the possibility of personal liability for acts that may be found to impinge on the constitutional rights of citizens.''White rejected that argument, saying, ''We do not believe that the security of the republic will be threatened if its attorney general is given incentives to abide by clearly established law.''

One Justice Department official, who asked not to be identified, said the department was ''certainly not alarmed by that holding.'' He emphasized that it is ''very important not to have to undergo the burden of trial'' and said the ruling allowing officials to appeal unfavorable rulings immediately is vital.

But Mark Lynch, a national security expert for the American Civil Liberties Union, hailed the decision as ''the first time in 13 years that the court has rejected a national security claim.''

''It's a terrific opinion,'' Lynch said, because it ''rejects the argument that there is absolute immunity for people performing national security functions, such as the heads of intelligence agencies . . . .'' He added that the ''wonderful thing'' about the ruling is that ''it says it is important to have damage suits in national security matters because there are very few other protections that individuals have against abuse.''

Mitchell, 71, now a business consultant in Washington, was convicted of charges in connection with the Watergate cover-up and was paroled from prison in 1979 after serving 19 months.

The lawsuit stems from a warrantless domestic wiretap in 1970 of antiwar activists who allegedly planned to kidnap Henry A. Kissinger, then national security affairs adviser.

Four justices joined White in saying that Mitchell deserved qualified immunity, but Chief Justice Warren E. Burger and John Paul Stevens would have given him total immunity. White, joined by Justices Harry A. Blackmun, William J. Brennan Jr. and Thurgood Marshall, rejected the total immunity claim and Justice Sandra Day O'Connor said she would not reach that issue to decide the case.

Justice William H. Rehnquist, a Justice Department official under Mitchell, did not participate in the case. Justice Lewis F. Powell Jr. did not vote on the decision after missing oral argument due to illness.

Several other lawsuits against Mitchell stemming from his authorization of warrantless national security wiretaps are pending.