A closely divided Supreme Court ruled yesterday that members of Congress may be sued for damages by employes claiming to be victims of sex discrimination or other unconstitutional denials of the equal protection of the laws.

The court rule, 5 to 4, that a right to sue and to seek damages can be implied directly under the Constitution when the guarantee of due process of law in the Fifth Amendment is violated.

The ruling was a setback for former representative Otto E. Passman (D-La.), who fired his deputy administration assistant, Shirley Davis, with a letter saying it was "essential" to replace her with a man even though she was "able, energetic and a very hard worker."

The case was sent back to the 5th U.S. Circuit Court of Appeals for a decision on whether Passman was shielded by the Constitution's "speech or debate" clause, which makes legislators accountable only to the House and Senate for their legislative acts.

If the clause does not protect Passman, "we apply the principle that "legislators ought generally to be bound by [the law] as are ordinary persons,'" Justice William J. Brennan Jr. wrote for the majority.

Two dissenting opinions denounced the ruling, saying it ignored the constitutional doctrine of the separation of powers among coequal branches of government.

"Although Congress altered the ancient 'spoils system' as to the executive branch and prescribed standards for some limited segments of the judicial branch, it has allowed its own members, presidents and judges to select their personal staffs without limit or restraint," Chief Justice Warren E. Burger wrote.

Justice Lewis F. Power Jr. protested "a blind exercise of judicial power without regard to . . . constitutional principles."

In addition, exercising the right to dissent orally, Powell contended that the rationale of the ruling cannot be limited to Capitol Hill. From now on, he said, members of the judicial and executive branches "will live under the threat" that they no longer will be able to control their personal staffs.

Justice Potter Stewart Dissented to the ruling on the sole ground that if the speech-or-debate clause immunized the firing, the case would be ended regardless of "the abstract existence" of a cause of action and liability for money damages.

Burger and Powell each signed the other's opinion, and Justice William H. Rehnquist signed their dissents as well as Stewart's.

The appeal court heard arguments on the relevance of the speech-or-debate clause but didn't discuss it in its opinion. Instead, it rule, 12 to 2, that the Fifth Amendment implied no right to Davis, a Monroe, La., widow with two grown children, to litigate her complaint.

The Civil Rights Act of 1964 bars sex discrimination in the federal workplace and allows government employes to seek redress in the courts. But, the 5th Circuit held, Congress provided an exemption for itself.

Justice Brennan wrote for the Supreme Court, however, that there is "no evidence" that Congress meant to prevent a victim of discrimination from seeking money damages from a legislator.

Powell disagreed, saying that Congress had barred its employes from "all" judicial relief.He raised the possibility that Congress may want to clarify the matter in new legislation.

Such legislation probably woud run into strong opposition, if a friend-of-the-court brief filed by 29 House members is a reliable indictor. Siding with Davis, they argued that the 1964 law "does not foreclose an action based on a constitutional claim on sex discrimination."

In filing the brief, they noted that Congress had failed three times in the last two years to give "full consideration on the merits" to fair-employment proposals for Capitol Hill.

Rep. Patricia Schroeder (D-colo.) said of the decision, "The last plantation apparently has been shot down."

She and Rep. Morris Udall (D-ariz.) have introduced a bill for a Capitol Hill counterpart of the Equal Employment Opportunity Commission.

The legislation apparently invited by Powell - and separately by Burger - would make Congress look "just . . . awful," Schroeder said.

Passman hired Davis as his deputy administration aide in Monroe in February 1974. She said she started at $18,000 a year, and expected an increased to $32,000 upon the "imminent" retirement of the persons holding the job of adminstrative assistant. But the congressman fired her six months later.

Davis sued for damages in the form of back pay. She also sought reinstatement, but that became impossible when Passman was defeated for renomination in 1976 after being in Congress 30 years.

Chief Justice Burger found in the majority opinion "the intimation that if Passman were still a member of the House, a federal court could command him, on pain of contempt, to reemploy Davis."

The intimation "represents an astonishing break with concepts of separate, coequal branches," Burger wrote. "I would categorically reject the notion that courts have any such power in relation to Congress."

A trial judge threw out Davis' suit on the ground that "the law affords no private right of action" for her claim. A 5th Circuit panel reversed that decision, 2 to 1, taking the position expressed by the Supreme Court yesterday. That panel was overturned by the full appeals court.

Yesterday's opinion grew out of a 1971 ruling that a cause of action for damages was implied under the Fourth Amendment for victims of an arrest and search made by federal agents without probable cause. CAPTION: Picture 1, FORMER REP. OTTO PASSMAN . . . accused of sex discrimination; Picture 2, JUSTICE WILLIAM J. BRENNAN JR. . . . author of majority opinion