Last August, after several staffers had been diverted from their regular jobs for nearly a year, the Environmental Protection Agency was ready to meet a court-ordered deadline and issue regulations to control toxic pollutants discharged into the water by 24 major industries.

But with the publication deadlines looming for the complex documents, four pharmaceutical firms and their trade group intervened to block the proposal involving their plants. First they tried to block it at EPA; then they enlisted the aid of the Office of Management and Budget, which, under an executive order by President Reagan, must sign off on all regulations.

The result was one of the testiest confrontations yet over OMB's controversial role of regulatory watchdog. Since Reagan took office, there has been criticism that back-door contacts between OMB and industry would subtly shape final regulations, though OMB's role and contacts with industry would remain secret. OMB officials have declined to keep records of their contacts with private parties.

During a frantic three-week period just before the November elections, EPA and the pharmaceutical industry threw figures and technical analyses back and forth at each other, while at OMB, Jim J. Tozzi, deputy administrator of the Office of Information and Regulatory Affairs, phoned the managers of two pharmaceutical plants to compile his own information on their pollution control equipment.

EPA officials and an attorney for Pfizer Inc. agree that the extent of their differences became clear in a late-August meeting at which EPA laid out its plans to establish new guidelines for the discharge of cyanide, as the court ordered, and then strengthen its 6-year-old rules covering organic chemical wastes discharged by the 339 plants where drugs are made.

The Pharmaceutical Manufacturers Association and the four firms, Eli Lilly & Co., Merck & Co., Hoffmann-La Roche Inc. and Pfizer, protested, saying the court order required no such changes in the rules. EPA officials concede this point, but say the changes were so closely tied to the court's requirements that it would be impossible to untangle them and still meet the court's deadline.

The pharmaceutical firms also argued that the new equipment they would have to install would be disruptive and expensive, costing $100 million, or more than four times EPA's estimate of $23 million. And that argument piqued OMB's interest the most.

The existing rules treat the pharmaceutical industry differently from most of the other industries whose organic wastes are discharged into lakes, streams and rivers, according to Steven Schatzow, director of EPA's water regulations and standards division.

When organic wastes are consumed by aquatic microorganisms, the process depletes the oxygen available for fish and other underwater life. The 1976 standard, simply stated, required pharmaceutical plants to reduce organic pollutants in their raw wastes by 90 percent.

Schatzow said this standard led to inequities within the industry, because firms whose raw waste was high in pollutants were held to a less rigorous standard than those whose waste was cleaner to begin with.

Following a consultant's report in June, 1980, EPA started to work toward a new, fixed standard so that all pharmaceutical plants would have to meet the same minimum requirement. This would reduce the burden on smaller plants whose waste was already more thoroughly treated, but increase equipment costs for about 10 large plants -- including plants operated by the largest firms.

In the August meeting with EPA officials, the pharmaceutical industry representatives criticized the 1980 study, according to several persons present. A few weeks later, they presented EPA with a written critique. But agency officials said this analysis was late and lacked crucial details, and told the firms they were going ahead with the proposal.

Okay, said Pfizer attorney Joan Z. Bernstein, we're going to OMB.

"The present controls are working. A great deal of money has already been expended," Bernstein, who served as EPA general counsel under President Carter, said last week. "What the heck? Courts second-guess people, Congress second-guesses people, OMB second-guesses people. Anybody representing a client who didn't use that route would be damn negligent."

She contacted Tozzi and, for good measure, contacted C. Boyden Gray, counsel to Vice President Bush, who heads the White House Task Force on Regulatory Relief. Bush served as a director of Eli Lilly & Co. from 1977 to 1979.

Tozzi said any calls to Gray were referred to Tozzi's office.

By the time Tozzi got involved, the court deadline was three weeks away. EPA sent the proposed rule over to OMB for the required review. "When the numbers came in, our respective staffs met on the numbers," Tozzi said. The data from both sides was inadequate, he said. So he asked Bernstein to set up a conference call so he could talk with the managers of two plants about waste discharge, pollution control technology and costs.

He also said that inadequacies in EPA's cost figures would have made it "very inopportune" to publish a final rule, but "as a proposed rule we have ample time to consider it."

Others at OMB didn't give as much weight to this distinction; both OMB's general counsel and Tozzi's boss, Christopher DeMuth, called EPA officials in late October to warn the agency about violating the executive order by publishing the rule without OMB's approval. The tension increased when EPA administrator Anne M. Gorsuch indicated she would sign the proposal, with or without OMB's blessing.

In the first week of November, she did just that. The proposal -- now changed to include a request for information about whether big firms should be regulated differently from small ones -- was signed and delivered on time.

Pfizer representatives are now reluctant to talk to reporters for fear of further offending EPA, to which they must make their case once again. But as far as Tozzi is concerned, "The process was healthy -- the agency and the outside groups now know . . . what protocol is required."