The giant budget bill just signed by President Reagan contained an unexpected and bitter pill for some drug makers: a provision that prohibits Medicaid payment for hundreds of prescription drugs that have long been in use but have never been proven effective.

Not only do the marketers of the drugs stand to lose millions of dollars a year, but also the provision neatly cuts the legs out from under the Department of Health and Human Services, which had won the first round of a lawsuit on the issue.

The drugs involved are those that were licensed for public sale a generation ago, before effectiveness as well as safety was a condition for legal sale. After an effectiveness requirement was added to new drug licensing procedures by Congress in 1962, these older drugs were reviewed by scientific panels, which in many cases found the drugs ineffective.

But in the absence of final rulings from the Food and Drug Administration, the drugs are still permitted to be sold and the Medicaid program will still reimburse the states if a doctor prescribes them for a Medicaid patient. Medicaid has been paying millions of dollars each year for these drugs.

Sidney Wolfe, who heads the Public Citizen Health Research Group (HRG), has been battling the Department of Health and Human Services on the issue, arguing that hundreds of millions of dollars are being wasted on these drugs and, worse, that as a result patients aren't getting the effective drugs they need. He has repeatedly requested HHS and Congress to take action, and HRG brought a lawsuit over the issue. The group lost in U.S. District Court in Washington, but was pondering an appeal.

Wolfe has emphasized that since 1971, HHS has refused to use these drugs in its own Public Health Service hospitals, even though it allows reimbursement for them under Medicaid.

But on a number of occasions in those years, HHS took the position that it could only disqualify the drugs from Medicaid reimbursement after the FDA made a final ruling -- a process so protracted that it can allow the drugs to linger on in Medicaid for years.

Now, as a result of an amendment placed in the budget bill by Reps. John D. Dingell (D-Mich.) and Henry A. Waxman (D-Calif.) and accepted without objection or discussion in conference with the Senate, many of these drugs may soon be barred from federal reimbursement under Medicaid.

FDA experts said the provision could lead to removal from Medicaid reimbursement of several widely sold drugs such as Librax, an anti-spasmodic used for ulcer patients, and dozens of others for which, so far, effectiveness has not been established.

Aides to Waxman and Dingell estimate that if the provision works out as planned, the federal and state governments will save at least $40 million the first year; some others say the figure may eventually double that or go higher.

The provision short-circuits the timetable for throwing these drugs out of the Medicaid reimbursement program.

Instead of waiting for a final FDA administrative determination, the Waxman-Dingell provision would bar the drugs from Medicaid at a much earlier stage: after the FDA had made a scientific finding that the drug lacked evidence of effectiveness and had published a notice that the maker could seek a hearing on the issue. Waxman and Dingell aides said this change could speed up removal by several years, since many proceedings stretch out that long after publication of the notice. The provision becomes effective in October.

Drug industry lobbyists had some inkling the provision was in the bill and the Pharmaceutical Manufacturers Association said, "We are against it."

But one drug lobbyist said the industry made no concerted effort to root it out of the bill because they were more concerned with a favorable drug patent measure that is pending and that they would like to see passed, and wanted to save their efforts for that.

The fight over the Medicaid drug provision had its roots in the 1962 Kefauver-Harris drug bill, which, for the first time, imposed the requirement that prescription drugs sold in the United States must be effective as well as safe. Several thousand drugs already on the market were reviewed for efficacy by the National Academy of Sciences and National Research Council, and some by the FDA as well; many were subsequently approved but others were removed from the market.

However, there are still a large number of drugs (estimates vary) that were found less than effective by the NAS/NRC but haven't been reviewed by the FDA or haven't finished FDA review. These are the ones still eligible for Medicaid reimbursement. Now, many of them may be thrown out.