The Supreme Court, in a unanimous ruling hailed by women's groups as a major victory, decided yesterday that businesses may be held liable for sexual harassment by supervisors even if the company is unaware of such conduct.

The decision, which came in a case involving a District bank employe, was written by Justice William H. Rehnquist, President Reagan's choice as the next chief justice.

"Without question," the court said in its first ruling in a sex harassment case, "when a supervisor sexually harasses a subordinate because of the subordinate's sex, that supervisor 'discriminates' on the basis of sex," in violation of federal law.

Rehnquist said Title VII of the Civil Rights Act of 1964 "affords employes the right to work in an environment free from discriminatory intimidation, ridicule and insult."

The ruling overturned a trial judge's decision that employers in sex harassment cases, as opposed to other discrimination cases, can be held liable only if they had been notified of the harassment and did nothing about it.

But Rehnquist, striking a middle ground between the trial judge and an appeals court ruling last year, said the appeals court "erred in concluding that employers are always automatically liable for sexual harassment by their supervisors. . . regardless of the circumstances of the case."

The ruling in Meritor Savings Bank v. Vinson, clears the way for a new trial in a case brought by Mechelle Vinson, who worked at a Northeast branch of what was then called Capital City Federal Savings and Loan. She began working there as a teller in 1974 and was an assistant branch manager before she was fired in 1978 for taking excessive leave.

Vinson then sued the bank and her supervisor, branch manager Sidney L. Taylor, saying that she had been constantly subjected to sexual harassment by Taylor. She said Taylor asked her to have sexual relations with him, claiming that she owed him sexual favors because he had obtained the job for her. Vinson said she eventually yielded for fear of losing her job.

Taylor denied the allegations and said Vinson was retaliating for a business dispute. Capital City, acquired in 1985 by an institution that later became Meritor Savings Bank, argued that it was unaware of the alleged discrimination and had not authorized it. Capital City, joined by other business groups, argued that federal law meant to protect people from "tangible losses," such as a denial of promotion, not "purely psychological aspects of the work place environment" such as a worksite where there is persistent sexual harassment.

Rehnquist rejected that view and said the trial judge erred when he did not allow Vinson to present as witnesses other female employes who had allegedly been subjected to similar harassment in such an allegedly "hostile environment."

Rehnquist also rejected the trial judge's conclusion that it was significant that the relationship between Vinson and Taylor was voluntary. "The fact that sex-related conduct was 'voluntary,' in the sense that she was not forced to participate against her will," Rehnquist said, "is not a defense to a sexual harassment suit" under federal law. The heart of "any sexual harassment claim," he said, "is that the alleged sexual advances were unwelcome."

Employer groups said yesterday's opinion was substantially better for business than the appeals court opinion, because under Rehnquist's opinion, employers could not be held automatically liable in every case and because they would be allowed to use in their defense evidence of an employe's "provocative" conduct or dress.

"There is something for everyone" in the opinion, said U.S. Chamber of Commerce General Counsel Stephan A. Bokat. He said the ruling "will encourage employers to put into effect programs and policies that would preclude the employer from being held liable should a supervisor engage in prohibited sexual conduct with an employe."

Eleanor Smeal, president of the National Organization for Woman, said the ruling "states definitively, for the first time, that sex harassment is discrimination and that it is definitely illegal." Employers are now on notice that they are required to set up procedures to make sure such discrimination does not occur, she said.

NOW Legal Defense Fund attorney Kathy Bonk said "we have been working with industry in the last couple of years and making progress, but since the high court took the case for review business has taken a 'wait-and-see' attitude. Few corporations do what Rehnquist is suggesting they do," she said. "What we can do now is say, 'okay gang, you have got to do it, read this decision.' "

Rehnquist's opinion, written long before his nomination, was the first time he had "issued an opinion on our side," Bonk said.

Rehnquist's views also contrasted sharply with those taken in this case by appeals court Judge Antonin Scalia, who will be nominated to take Rehnquist's seat on the Supreme Court if Rehnquist is confirmed as chief justice.

Scalia had joined an opinion by appeals court Judge Robert H. Bork, who insisted that harassment is not equivalent to discrimination and was not banned by federal law. In addition, Bork argued that if the relationship between Vinson and Taylor, if voluntary, would be a substantial defense to any claim of harassment. Scalia and Bork were in the minority on the appeals court.

In another decision yesterday, the court upheld a 1983 law aimed at protecting the financial well-being of the Social Security system, ruling unanimously that state and local governments may not withdraw their employes from the system. The case is Bowen v. Public Agencies Opposed to Social Security Entrapment.

In a third decision, the court upheld, 5 to 4, Pennsylvania's law requiring a mandatory five-year sentence for using a handgun during commission of certain felonies. The justices turned back an argument in McMillan v. Pennsylvania that the law is unconstitutional because it permitted sentencing by a judge who did not have to determine beyond a reasonable doubt that the defendant had a handgun.