A federal judge here temporarily barred the Potomac Electric Power Co. yesterday from implementing a sweeping set of drug-testing rules that mandate the firing of employes who refuse to submit to a search of themselves or their possessions or to provide urine or blood samples, as well as those who test positive for drug use.

U.S. District Judge Harold H. Greene described the rules, which were adopted Thursday and were to become effective immediately for the utility's 5,300 employes, as "Draconian measures" that force employes to "undergo invasions of privacy which are almost unheard of in a free society or they will be summarily fired."

In granting a temporary restraining order sought by Local 1900 of the International Brotherhood of Electrical Workers, Greene said in court that he was "well aware, having had the unfortunate experience of having to try many drug cases" that "the drug menace is certainly a terrible menace."

However, he said, "That does not mean that we must resort to hysterical measures, particularly by a company which, while important certainly to safety and well-being and welfare of our city . . . is hardly in the forefront of the danger as would be, for example, airline pilots or CIA operatives."

He also noted that Pepco intended to impose the rules on clerks and secretaries as well as other workers, and that workers could be fired for using drugs even on weekends and vacations.

Since 1981 Pepco has been testing job applicants and employes suspected of having drug problems. William H. Jones, Pepco's vice president for corporate affairs, said the new rules were an effort "to help our employes understand what their responsibilities are" and to satisfy complaints by the union "that the rules we've had in the past were imprecise."

The new rules would permit random testing of workers and firing on the basis of a single, unconfirmed positive test, but Jones said the company did not plan such firings. "The whole set of rules basically reflects the policy that has been in force here for some time," he said.

However, Jones said that under the company's earlier practice, employes who tested positive for drugs or refused tests or searches "would have been handled on a case-by-case situation" rather than being automatically fired, as mandated by the new rules.

Jones said the utility did not plan to appeal Greene's order, which is in effect for five days. The ban could be extended through a preliminary injunction, which the union is seeking while the rules are submitted to arbitration. Pepco's earlier rules are the subject of a union grievance proceeding before an arbitrator.

Pepco spokesman Thomas Welle said the new rules were spurred by company officials' belief that, although the utility does not have "a major drug problem," there has been an increase in drug use.

He said the change was made "to ensure a safe and productive work place free from the effects of substance abuse."

Drug testing of workers has grown rapidly in recent years as the tests have become economical for employers and as growing drug abuse has, in the view of many employers, cut into worker productivity and threatened the safety of employes and customers. The President's Commission on Organized Crime recommended earlier this month that mandatory testing be instituted for government workers and employes of contractors that receive government funds.

Greene said in court yesterday that he was not aware of "any organization . . . that has gone this far, and has sought unilaterally without consultation or without negotiation to impose these kinds of drastic measures.

"Even the United States government, which has far more at stake in terms of drug users in its ranks than Pepco, is just talking about it," he said.