The Supreme Court ruled 5 to 4 yesterday that the Social Security Administration must make old-age survivors' benefits as easily available to widowers as to widows.

The decision qualifies nearly 300,000 widowers whose working wives had paid Social Security taxes for monthly benefits ranging from about $100 to $400, depending upon a wide range of individual circumstances.

Without saying so explicityly, the court hinted, and may later rule, that 200,000 aged husbands of wives who also had worked and paid the taxes are newly eligible for payments.

For a financially strained Social Security treasury, the cost of newly qualifying the 500,000 men in both groups would be about $500 million in the first year, an agency spokesman said in Baltomore.

The case was originated by Leon Goldfarb, now 72, a retired federal employee. His wife, Hannah, had worked for almost 25 years as a secretary for the New York City school system.

When his wife died, Goldfarb applied for old-age survivors' benefits. The agency turned him down because the 1950 amendments making widower eligible require that a wife at the time of her death had to have been providing at least half of her husband's support.

In practical terms, Goldfarb would have qualified only if his wife had contributed three-fourths of their combined income - half for her upkeep, one-quarter for his.

In contrast, a law enacted in 1939 makes widows eligible for the benefits regardless of dependency. Other eligibility standards, including a minium age fo 60, are the same for men and women.

Thus the Federal Old-Age, survivors, and Disability Insurance Benefits program, embodying both the 1939 and 1950 legislation, makes men but not women prove dependency on a deceased spouse although both have paid Social Security taxes at equal rates.

In an opinion for four members of the majority justice William J. Brennan Jr. said that this distinction invidiously discriminates against female workers by affording them less protection for their surviving spouses.

Brennan said that the constitutional guarantees of due process and equal protection forbid such a distinction when the justifications for it are merely "archaic and overbroad" generalizations or "old notions," such as assumptions about the dependency of women on men. These notions are more consistent with traditional "role-typing" than with contemporary reality, he said.

As for Congress, Brennan said it had sought to create not "differential treatment," but "to aid the dependent spouses of deceased wage earners," based on "a presumption that wives are usually dependent."

While providing the fifth vote to make a majority, Justice John Paul Stevens rejected the contention that the law discriminates against deceased women workers. ". . . The relevant discrimination in this case is against surviving male spouses," he said.

In an opinion for the dissenters, Justice William H. Rehniquist said that law's more favorable treatment of certain elderly widows than of their widower counterparts is not "invidious."

Stevens agreed. The distinction doesn't imply male inferiority, condemn a large class on the basis of the misconduct of an unrepresentative few, or add to the burdens of an already disadvantaged minority, he said.

Instead, Stevens said, "this discrimination against a group of males is merely the accidental byproduct of a traditional way of thinking about females."

The decision affirmed a three-judge District Court panel which said, "Mrs. Goldfarb was entitled to the dignity of knowing that her Social Security tax would contribute to their joint welfare when the couple or one of them retired and her husband's welfare should she predecease him." The panel added.

"She paid taxes at the same rate as men and there is not the slightest scintilla of support for the proposition that working women are less concerned about their spouses' welfare in old age than are men."

The District Court panel also rejected a dependency requirement in the law for husbands of covered women workers. Brennan's opinion, reporting this in a footnote, said, "These gender-based classifications have been uniformly held to be unconstitutional."

Challenges to the dependency requirement for husbands are pending in the high court, along with other cases involving sex-based distinction in the Social Security law.

In 1975, the court invalidated a Social Security Act provision granting survivor benefits to widos but not widowers with children. The court's reason was the same as Brennan's yesterday: the difference is a sex-based discrimination against deceased women workers who paid Social Security taxes.

In 1973, the court struck down an Air Force rule giving a dependency allowance to the spouse of a serviceman but not of a serviceman.

Johning Brennan and Stevens in yesterday's decision were Justices Byron R. White, Thurgood Marshall and Lewis F. Powell Jr. Chief Justice Warren E. Burger and Justices Potter Stewart and Harry A. Blackmun joined Rehnquist.