The Senate Judiciary Committee passed legislation yesterday that would open the way for five American pharmaceutical firms to avoid a trial that could force them to pay hundreds of millions of dollars to foreign countries that have accused the drug manufacturers of overcharging them.

The legislation would have the effect of negating a 1978 Supreme Court ruling that a foreign country, in this instance India, can sue U.S. firms in American courts on charges of price fixing, just as American citizens can.

The Senate bill would require foreign nations to have had a similar law in effect to be eligible to bring suit under the antitrust laws. It also would limit judgments to actual damages, rather than triple damages permitted by the court's ruling.

The Public Citizen Health Research Group criticized the bill as "special interest legislation of the worst kind, . . . virtually unprecedented intervention in an ongoing judicial proceeding."

Former senator Adlai E. Stevenson (D-Ill.), representing the National Association of Manufacturers, testified at the April 30 hearing on the bill that it is "an appropriate congressional response. . . . No other country in the world" would permit a foreign nations as plaintiffs. It simply imposes conditions on their right to sue American citizens. . . ."

The only objection to the proposal was raised by Sen. Arlen Specter (R-Pa.), who questioned whether it should be retroactive.

Frank A. Duckworth, vice president and general counsel of Pfizer Inc., a major beneficiary of the legislation, testified that "fairness requires" the legislation be made retroactice to protect defendants "threatened . . . in cases based on principles Congress chose to reject."

A trial is scheduled in U.S. District Court in Philadelphia next month in which Pfizer and four other drug manufacturers have been accused by India, West Germany, the Philippines, Colombia and Iran of price fixing in the sale of the antibiotic tetracycline in their countries.

Pfizer, which obtained the original patent in 1955, and the other defendants, Bristol-Meyers, Cyanamid, Upjohn and Olin, have according to one estimate, already paid out more than $200 million in our-of-court settlements over the last two decades in connection with the drug.

During a price-fixing trial in New York in 1970, Justice Department prosecutors showed that production costs for 100 tablets of tetracycline varied from $1.59 to $12 between 1953 and 1961. Yet through all those years, the five suppliers charged pharmacists an unvarying $30.60, and in turn, the druggists almost always charged retail customers $51.A fair price over the years, according to David L. Shapiro, a Washington antitrust lawyer who designed the settlement, would have been $6 wholesale and $10 retail.

Among those voting in favor of the legislation yesterday were six committee members who together received a total of $9,500 in campaign contributions from Pfizer last year.

Sen. Charles McC. Mathia (R-Md.), who was one of the recipients, said the $2,500 he received from Pfizer last Oct. 19 had "no relationship" to his support of the bill. His press spokesman, Jack Eddinger, said Mathias got $4,000 from political action committee of five pharmaceutical firms last year, which he called "an insignificant amount" when compared to total contributions of $860,798, of which $302,465 came from PACs.

Burt Rosen, assistant director of government relations for Pfizer, said "there is no relation between the Pfizer contributions and the bill. We never tied on to the other." Rosen said Pfizer contributes to candidates "who uphold the free enterprise system," and to those who have Pfizer plants in their states and districts.