WASHINGTON (AP) _ Individual pickets have a right to carry signs within 500 feet of foreign embassies in the nation's capital but police may disperse groups of three or more protesters there, the Supreme Court ruled Tuesday.

By a vote of 8-0, the justices upheld the District of Columbia's ban on groups demonstrating within 500 feet of embassies if police have reason to believe the protesters pose a threat to ''the security or peace of the embassy.''

But by a separate 5-3 vote, the court said the city's anti-picketing prohibition that prevents even one or two people from carrying signs within 500 feet of the embassies violates free-speech protections.

Justice Sandra Day O'Connor, in her opinion for the court, said a blanket ban on signs that might be offensive to foreign diplomats goes too far.

''It may serve an interest in protecting the dignity of foreign missions, but it is not narrowly tailored,'' she said. ''A less restrictive alternative is readily available.''

For example, she said, it would be constitutional to ban picketing that is designed to intimidate, coerce, threaten or harass a foreign official.

That type of ban has been adopted by Congress for all areas of the nation with the exception of the District of Columbia.

Officials of the District of Columbia government have said they are considering adopting a law based on the congressional model.

Tuesday's ruling allows District police to continue to enforce a ban on demonstrations near embassies when at least three people take part and police fear there will be disruptions.

O'Connor said police must ''reasonably believe that a threat to the security or peace of the embassy is present.''

Banning such gatherings ''does not prohibit peaceful congregations,'' she said. The ban ''is limited to groups posing a security threat.''

O'Connor rejected arguments that such a ban gives police too much discretion to break up demonstrations.

She said the test for deciding whether a demonstration is illegal ''is whether normal embassy activities have been or are about to be disrupted.''

The ruling partially overturned a 1986 decision by the U.S. Circuit Court of Appeals in Washington upholding all aspects of the District of Columbia's ban on protests near embassies.

That ruling was written by former Judge Robert H. Bork, who recently retired from the appeals court. Bork was President Reagan's first choice to fill a Supreme Court vacancy last year but was rejected by the Senate in a bitter fight.

Tuesday's decision is believed to be the first time the high court gave full review to an opinion written by Bork. His backers during the Senate confirmation fight emphasized that he had never been reversed by the high court.

The appeals court ruling that Bork wrote in the embassy case said free- speech interests of the demonstrators were outweighed by the need to protect foreign emissaries.

The 500-foot restrictions were challenged by Michael Boos, J. Michael Waller and Bridget Brooker, members of the Young Conservative Alliance of America.

They wanted to carry signs in front of the Soviet Embassy saying ''Release Sakharov,'' referring to Soviet dissident Andrei Sakharov, who was allowed in 1986 to return to Moscow, ending his internal exile in the city of Gorky.

The demonstrators also planned to picket the Nicaraguan Embassy with placards saying ''Stop the Killing'' in opposition to the Sandinista government there.

The conservatives also said they were not receiving equal treatment with opponents of the South African government who have demonsrated near that nation's embassy in Washington.

Many of those protesting South African racial policy have been arrested and then freed without being prosecuted.

Joining O'Connor in both phases of Tuesday's ruling were Justices William J. Brennan, Thurgood Marshall, John Paul Stevens and Antonin Scalia.

Dissenting and voting to uphold the ban on individual picketing were Chief Justice William H. Rehnquist and Justices Byron R. White and Harry A. Blackmun.

Justice Anthony M. Kennedy did not take part in the decision.

In other action, the court:

-Unanimously ruled in a case from Michigan that states are barred from regulating the way interstate natural gas companies issue securities to finance their operations.

-Heard arguments in a case from Illinois on whether the so-called Miranda warnings police give criminal suspects are adequate to insure their right to legal help. A decision is expected to be announced by July.