Retail giant Walmart filed suit Thursday against the US Justice Department over what it said was an unfair attempt to hold it legally responsible for certain sales of opioid drugs.

The lawsuit is the latest legal battle linked to the opioid crisis in the United States, where widespread abuse has led to government efforts to address the problem and hold drugmakers accountable.

In its lawsuit brought before a federal court in Texas, the US retailer says its pharmacists and pharmacies were being put "in an untenable position" by the government.

The suit, which also names the US Drug Enforcement Administration (DEA), says Walmart was acting preemptively to head off a separate civil suit that the Justice Department has been preparing to file against it.

Walmart said the government's rules were unclear and that pharmacists could not be expected to know when a prescription written by a licensed doctor should not be filled.

"Walmart and its pharmacists should not be held responsible for the government's failures to address the opioid crisis," the suit says.

With the help of aggressive marketing from pharmaceutical companies, particularly through doctors, prescriptions for highly addictive opiate painkillers that had previously been reserved for serious cases skyrocketed in the late 1990s.

According to the Centers for Disease Control and Prevention, more than 500,000 Americans have died of opioid overdoses -- both prescription and non-prescription -- since 1999.

Walmart said the government's rules were unclear and that pharmacists could not be expected to know when a prescription written by a licensed doctor should not be filled Walmart said the government's rules were unclear and that pharmacists could not be expected to know when a prescription written by a licensed doctor should not be filled Photo: AFP / NICHOLAS KAMM

Walmart accuses the DEA of seeking to pass blame for its failures.

It alleges the agency "authorized manufacturers to produce ever-increasing quantities of the drugs, and largely abandoned its most potent enforcement tools against bad actors."

It also said that "nearly 70 percent of the doctors whose prescriptions" the government intends to challenge "maintain their DEA prescription privileges to this day."

Walmart alleges the government has spent years and considerable amounts of money on a criminal investigation that has not produced an indictment and was now turning to a civil lawsuit instead.

It is calling on the court to state that the company and its pharmacists are not subject to the legal responsibility with which the government is seeking to brand it.

Other large companies, including drug distributors Cardinal Health and McKesson, have been targeted in lawsuits by local and state authorities that accuse them of turning a blind eye to millions of opioid prescriptions despite knowing their addictiveness.

A settlement was reached between three distributors and two Ohio counties in October 2019, raising the possibility of a larger settlement.

On Wednesday, the Justice Department announced that Purdue Pharma, manufacturer of the drug OxyContin, had agreed to plead guilty as part of a deal worth some $8.3 billion.