The distributors of powerful prescription opioids and the Drug Enforcement Administration failed to stop the flow of millions of pills into rural West Virginia despite rampant warning signs that the pills were being diverted for abuse, inertia that contributed to the nation’s opioid epidemic, a congressional report has found.

A report from the majority staff of the House Energy and Commerce Committee found that distributors, which fulfill orders for prescription drugs to pharmacies, failed to conduct proper oversight of their customers by not questioning suspicious activity and not properly monitoring the quantity of painkillers that were being shipped to individual pharmacies.

The committee also found that the DEA did not properly use a database that aims to monitor the flow of powerful prescription painkillers from manufacturers to sellers, something that could have allowed federal agents — in real time — to notice that millions of pills were being sent to pharmacies in West Virginia. The agency also curtailed enforcement of distributors, the report found, and infighting inside the agency affected the way cases were handled.

The 324-page report, the culmination of an 18-month investigation of alleged pill dumping in West Virginia, shows how mistakes and lack of oversight led to a massive influx of pills there, much of which ultimately fueled the black market sale and illegal abuse of opioids, including oxycodone.

The Controlled Substances Act requires distributors and the DEA to diligently report and track data about such drugs, and the report found that neither did. West Virginia has been the epicenter of the opioid crisis; the state has the highest overdose death rate in the country.

“Taken altogether, the Committee’s report outlines a series of missteps and missed opportunities that contributed to the worsening of the opioid epidemic in West Virginia,” the report says. “While focused on a narrow part of West Virginia, the report raises grave concerns about practices by the distributors and the DEA nationwide.”

The committee investigated the nation’s three largest drug distributors: Cardinal Health, AmerisourceBergen and McKesson Corp. The report said the companies combined sent more than 900 million doses of hydrocodone and oxycodone to West Virginia from 2005 to 2016. It also looked at two regional distributors: Miami-Luken and H.D. Smith. The report said those companies made “inordinate shipments” of opioids to pharmacies in the state during the same time frame.

Cardinal Health said in a statement that it commends the committee for “examining this complex national public health issue.” The company said it will “continue to implement rigorous anti-diversion controls” and continue to raise awareness about the dangers of overprescribing painkillers.

AmerisourceBergen, which recently acquired H.D. Smith, said the report primarily focuses on whether the company did due diligence regarding prescribing physicians, but it says the company has “virtually no interaction with physicians and limited legal ability to gather information on their practices and prescribing behavior.” The company said that heightening standards for all parties in the opioid supply chain “would provide significant value to distributors.”

Richard H. Blake, outside counsel for Miami-Luken, declined to comment, saying he was reviewing the report ahead of its slated public release Wednesday.

McKesson did not respond to requests for comment Tuesday.

On Wednesday, after the report was released, DEA spokesman Melvin Patterson said the agency has upgraded its software program so it can more proactively investigate suspicious opioid orders. He said the changes have led to an increase in investigations into, and prosecutions of, manufacturers, distributors and providers during the past three years.

Starting in 2005, the DEA held one-on-one meetings with distributors to remind them of their legal obligation to prevent pills from being diverted to the black market, and the agency sent letters to all distributors in 2006 and 2007 to reiterate that obligation, according to the report.

Those letters did not work, the report concluded. Cardinal Health was fined $34 million in 2008 to resolve allegations that it failed to report suspicious orders, and McKesson was fined a little more than $13 million.

Despite paying the fines, the report alleges that the distributors continued to look the other way, allowing pills to flood into West Virginia. The report said that many of the distributors shipped pills to pharmacies with no regard for how many pills a store should need to have in stock based on the population it serves; during a two-week period in 2008, Cardinal increased what it sent to a pharmacy in Williamson, W.Va., more than 1,500 percent.

The report also said that distributors continued to pump pills into pharmacies even after it became clear that doctors and physicians who practiced hundreds of miles from the pharmacies were writing suspicious prescriptions to be filled there.

AmerisourceBergen started working with Westside Pharmacy in Oceana, W.Va., in 2011, the report said. In documents provided to the committee, the company gave a list of five pain doctors who wrote prescriptions filled at the pharmacy. One doctor was based in Pembroke, Va., nearly 100 miles from the town, and another practiced in Washington, D.C., 345 miles away. The report said four of the five doctors “have either been subsequently convicted of, or indicted on, criminal charges related to their controlled substance prescribing or are currently under federal investigation.”

The report found that the DEA’s use of administrative enforcement actions against distributors plummeted from 58 in 2011, to five in 2015.

“Our bipartisan investigation revealed systemic failures by both distributors and the DEA that contributed to — and failed to abate — the opioid crisis in West Virginia,” Energy and Commerce Committee Chairman Greg Walden (R-Ore.) and ranking Democrat Frank Pallone Jr. (N.J.) said in a joint statement.

The report lists several legislative and policy recommendations, such as calling on Congress to create more stringent requirements for reporting suspicious orders. It also urges the DEA to create a platform capable of tracking order data in real time and asks the agency to review staffing in the parts of the country hardest hit by the opioid crisis with the goal of ensuring there are adequate resources for scrutinizing pharmacies where there appear to be suspicious orders.

This article has been updated.