The Supreme Court ruled yesterday that when police obtain a warrent to search a public place, such as a tavern, they do not necessarily have a right to frisk patrons who happen to be there.

In the first constitutional ruling of its new term, the court outlawed such searches as an unreasonable invasion of privacy.

The juctices, voting 6 to 3, struck down an Illinois man's conviction for heroin possession. They ruled that the drug should not have been used as trail evidence because it was seized unconstitutionally.

Ventura Ybarra was arrested in a March 1, 1976, police raid on the Aurora Trap, a tavern in Aurora, Ill. When police officers -- investigating alleged drug trafficking by an Aurora Tap bartender -- staged the raid, Ybarra was one of about a dozen patrons present.

The police did not suspect Ybarra of any crime, but decided to search all patrons for concealed weapons. Some heroin was found in Ybarra's pants pocket.

Wednesday's ruling means Illinois authorities must free Ybarra or give him a new trial in which the heroin will be excluded as evidence.

"Although the search warrant . . . gave the officers authority to search the premises and to search [the barender], it gave them no authority whatever to invade the constitutional protections possessed individually by the tavern's customers," Justice Potter Stewart wrote for the courts majority.

The Constitution's Fourth Amendment protects individuals against unreasonable police searches and seizures. A long series of court rulings have established that police must convince a judge or magistrate there is "probable cause" to suspect criminal activity before a search warrant can be obtained.

But in 1968 the Supreme Court made an exception to the "probable cause" rule and allowed police to frisk someone to search for a weapon when an officer reasonably believes one has been concealed.

Illinois authorities had argued that the 1968 decision, called Terry vs. Ohio, authorized the search of everyone in the Auroura Tap for weapons.

The high court's three dissenters agred, but Stewart's majority opinion said, "Nothing in Terry can be understood to allow a generalized cursory search for weapons . . ."

Stewart was joined by Justices William J. Brennan Jr., Byron R. White, Thurgood Marshall, Lewis F. Powell Jr. And John Paul Stevens. w

Chief Justice Warren E. Burger and Justices Harry A. Blackmun and William H. Rehnquist dissented. In an opinion of all three, Burger said that "when police execute a search warrant for narcotics in a place of known narcotics activity they may protect themselves by conducting a Terry search.

Burger said police should not be required "to assume that they will not be harmed by patrons of the kind of establishment shown here, something quite different from a ballroom at the Waldorf."

Although a specific Illinois law authorized the search of all persons at a public place targeted by a search warrant, the ruling never specifically invalidated the law.