The Supreme Court ruled yesterday that minor political parties may conceal their campaign expenditures and contributors as protection against harassment or Watergate-style government surveillance.

The ruling, which allows exemptions from both state and federal campaign disclosure laws, stemmed from a challenge brought to Ohio's campaign finance disclosure law by the Socialist Workers Party, which was targeted by the FBI in the 1960s and 1970s for what the court called a "massive" campaign of disruption.

The decision, written by Justice Thurgood Marshall, could also cover such parties as the Libertarian or the Communist, or any other small political party that can show a history of harassment that might deter someone from supporting it.

The justices were unanimous in freeing qualifying groups from disclosing lists of contributors. Three justices, in a statement written by Justice Sandra D. O'Connor, objected to the exemption from disclosure of expenditures, saying it could allow the covering up of vote-buying, slush funds, dirty tricks and bribes.

Minor parties "whose short-term goal is merely recognition," she said, "may be as tempted to resort to impermissible methods as are major parties and the resulting deflection of votes can determine the outcome of the election of other candidates."

The court's decision in Brown v. Social Workers '74 Campaign Committee chips away at some of the election laws enacted over the last decade. Both liberals and conservatives on the court have indicated concern that they infringe First Amendment guarantees of free speech and free political association.

In 1976, the justices invalidated major portions of the federal election law reforms. That ruling also suggested that minor parties might enjoy even more freedom because of their vulnerability.

Citing the earlier ruling, Marshall said "the right to privacy in one's political associations and beliefs" protects the small parties from the disclosure laws.

The court indicated that only parties that raise small amounts of money and have little chance of electing their candidates might qualify for exemptions, and then only after they showed a "reasonable probability" of "threats, harassment or reprisals" based on their history.

Government does not need to regulate such parties as stringently as major parties, Marshall said, because they don't have large amounts of money to abuse or numbers of office-holders to be corrupted.

Yesterday's ruling is likely to produce numerous lawsuits. Election law experts noted it leaves unclear whether a party backing someone like John B. Anderson or Eugene McCarthy, both of whom ran independent presidential campaigns, might be eligible under some circumstances.

They also expressed concern about the possibility that, under the decision, large sums of money could be secretly contributed and spent to help a useful minor party effort.

Marshall disagreed with O'Connor on exemptions for expenditures. "Disbursements may also go to persons who choose to express their support for an unpopular cause by providing services rendered scarce by public hostility and suspicion," Marshall wrote.

"Should their involvement be publicized, these persons would be as vulnerable to threats, harassment and reprisals as are contributors whose connection with the party is solely financial."

Justices William H. Rehnquist and John Paul Stevens joined O'Connor's concurrence. Justice Harry A. Blackmun agreed with most of the majority ruling but filed a separate statement saying it had prematurely decided some issues in the case.