The Supreme Court yesterday upheld a law giving preference to veterans in public employment even though it works to the drastic disadvantage of women.

The justices voted 6 to 3 nullify a ruling by a lower court that had invalidated the Massachusetts veterans' preference law in civil service hiring. The lower court said the law's impact on women was inadvertently so harsh as to deny them the equal protection of the laws guaranteed by the Constitution.

Forty-six states now have laws similar to Massachusetts. Congress also has given veterans an edge in federal hiring, although Civil Service Commission Chairman Alan K. Campbell said in August that he wants to curtail it.

The justices sent the ruling back to a sharply divided panel of three federal judges "for further consideration in light of" a 1976 Supreme Court ruling that a discriminatory impact without a proved discriminatory intent is insufficient to make a law or practice unconstitutional.

The justices issued no opinions. Three of them - Justices William J. Brennan Jr., Thurgood Marshall and Lewis F. Powell Jr. - noted that they would have heard oral arguments in the case.

The Massachusetts case was initiated by Helen B. Feeney, who went to work for the state civil defense agency as senior clerk-stenographer. She was the agency's federal funds and personnel coordinator when she was laid off in March, 1975.

Over the years, Feeney repeatedly had taken state civil service examinations for better jobs and scored high, only to be knocked out by the veterans' preference.

In 1973, for example, she took an exam for an administrative post at a mental health center. Her score, 92.32 out of a possible 100, was high enough to get her the job. But she ended up being ranked behind 11 male veterans whose grades were higher only because of the preference.

Under the Massachusetts law, the highest preference goes to disabled veterans. Then come other veterans and widows and widowed mothers of veterans. Nothing prohibits competition from women, few of whom become veterans. From 1918 to 1942 the armed services accepted women only as nurses.

The result has been that few women have been hired for or promoted into civil service jobs not shunned by men.

The three-judge panel recognized rewarding veterans as "a worthy state purpose," but said the Massachusetts formula "succeeds at the absolute and permanent disadvantage" of women, who suffer a "disastrous" impact."Few, if any, females have ever been considered for the higher positions in the state civil service," the majority said.

In another major action, the court agreed to decide whether a federal legislator - Sen. John L. McClellan (D-Ark.) - immunized against a lawsuit for allegedly unconstitutional conduct by the constitutional provision that legislative speech or debate can be questioned only in the Senate or House.

The justices granted McClellan's petition to review a decision by the U.S. Court of Appeals here that he could be sued for damages by Alan and Margaret McSurely in connection with an investigation by a subcommittee the senator headed.

The case goes back to 1967, when the McSurelys were organizers for the Southern Conference Educational Fund in Kentucky, and when the Senate authorized McClellan to investigate causes of disorder then racking the nation.

Pike County authorities arrested the couple and seized materials from their home, including love letters to Margaret McSurely from her former employer, the late Washington columnist Drew Pearson. The letters addressed her as "Dear Cucumber."

A panel of three federal judges ruled that the arrests, made under a state sedition law, were unconstitutional, and ordered impoundment of the seized papers.