Federal prosecutors have opened a criminal investigation into whether pharmaceutical companies intentionally allowed opioid painkillers to flood communities, employing laws normally used to go after drug dealers, according to people familiar with the matter.

The investigation, if it results in criminal charges, could become the largest prosecution yet of drug companies alleged to have contributed to the opioid epidemic, escalating the legal troubles of businesses that already face complex, multibillion-dollar civil litigation...