Under the Drug Quality and Security Act announced Wednesday, traditional compounders would largely remain under the jurisdiction of state boards of pharmacy while larger operations would be regulated by the Food and Drug Administration (FDA).
Lawmakers had urged for a clarification of the FDA's duties following a multistate outbreak of fungal meningitis that has killed more than 60 people since last year.
The deaths were caused by tainted steroid injections produced by the New England Compounding Center, a now-shuttered company whose safety violations were never fully penalized by regulators.
The outbreak prompted a series of hearings in both the House and Senate and a vigorous debate over whether the FDA deserved new powers to oversee compounding.
Republican and Democratic leaders praised the final agreement as a victory for patients and victims' families and a move against further tragedy.
"This legislation is a major stride toward the goal of ensuring the quality and safety of the medicines Americans rely upon every day," said House Energy and Commerce Committee Ranking Member Henry A. Waxman (D-Calif.) in a statement.
"This is undoubtedly a step forward for public health."