The Supreme Court ruled yesterday that federal, state and local public employes cannot be routinely fired just because they belong to the "wrong" political party.

Such dismissals, central to the political patronage system, violate employes' constitutional free speech guarantees, the court ruled.

Because the justices used constitutional grounds for their ruling, it overrides any laws. It may also be used to disrupt the time-honored spoils system in which the victors purge the government of thousands of officials belonging to the losing party.

Under current federal law, a new administration in the White House could fire several thousand officials belonging to the other party whose jobs are labeled "confidential" or "policymaking." But with yesterday's opinion -- still being studied by government attorneys -- that will no longer be so easy.

The question, the court said, "is not whether the label 'policymaker' or 'confidential' fits a particular position; rather, the question is whether the hiring authority can demonstrate that party affiliation is an appropriate requirement for the effective performance of the public office involved."

The ruling "eviscerates" the patronage system, said dissenting Justice Lewis F. Powell Jr., joined by Justices William H. Rehnquist and Potter Stewart, by incorporating a "national civil service" into the First Amendment.

Two Republican assistant public defenders in Rockland County, N.Y., brought yesterday's case (Branti vs. Finkel) after their dismissal by a newly chosen Democratic public defender. The Democrat, citing the Supreme Court's last ruling on patronage in 1976, argued that the jobs were unprotected because they were policymaking and confidential positions.

But Justice John Paul Stevens, for the 6-to-3 majority, went well beyond the 1976 ruling yesterday. "If the First Amendment protects a public employe from discharge based on what he said, it must also protect him from discharge based on what he believes," Stevens wrote.

"His beliefs cannot be the sole basis for derpiving him of continued public employment."

The government can attempt to prove that the political affiliation is of "vital importance" to the specific job, the justices said. But "that conclusion would not depend on any finding that the job involved participation in policy decisions or access to confidential information."

"Rather, it would simply rest on the fact that party membership was essential to the discharge of the employe's governmental responsibilities."

That requirement, dissenters noted, places a heavy burden on the government if it wants to fire someone for political reasons. Currently, tens of thousands of local and state employes and about 2,700 top federal workers are exempt from civil service protections as "policymaking" or "confidential" employes.

"Many public positions previously filled on the basis of membership in national political parties now [under the ruling] must be staffed in accordance with constitutionalized civil service standards that will affect the employment practices of federal, state and local governments," wrote Powell.

"The court's vague, overbroad decision may cast serious doubt on the propriety of dismissing United States attorneys as well as thousands of other policymaking employes at all levels of government, because of their membership in a national political party.

". . . In my view, the court is not justified in removing decisions so essential to responsible and efficient governance from the discretion of legislative and executive officials.

"Patronage appointments help build stable political parties by offering rewards to persons who assume the tasks necessary to the continued functioning of political organizations," Powell said.

Stewart wrote a separate dissent.

Chief Justice Warren E. Burger and Justices William J. Brennan Jr., Byron R. White, Thurgood Marshall and Harry A. Blackmum joined Stevens in the majority.