As investigators closed in on Purdue Pharma, the maker of the opioid painkiller OxyContin, more than a decade ago, members of the family that owns the company began shifting hundreds of millions of dollars from the business to themselves through offshore entities, the state of New York alleged in a lawsuit on Thursday.

The legal complaint, released at a news conference by the state attorney general Letitia James, was heavily redacted. Even so, it contains striking details alleging systematic fraud not only by the Sacklers but by a group of large but lesser-known companies that distributed alarming amounts of prescription painkillers amid a rising epidemic of abuse that has killed hundreds of thousands of people nationwide.

The major pharmaceutical distributors — Cardinal Health, McKesson and Amerisource Bergen — warned pharmacies when their monthly opioid limits were approaching, then helped them manipulate the timing and volume of orders to circumvent the limits, the complaint charged. On the rare occasion when a distributor would conduct “surprise” audits of its customers, it would often alert them in advance, the complaint says.

Over the past two decades, more than 200,000 people have died in the United States from overdoses involving prescription opioids, according to the Centers for Disease Control and Prevention. About 200,000 more have died from overdoses involving illegal opioids, like heroin.