A 28-year-old man has been arrested Wednesday morning on federal charges alleging that he sold counterfeit pharmaceutical narcotics containing the powerful opioid fentanyl to rapper Mac Miller two days before he died of a drug overdose last year.

Cameron James Pettit was arrested and charged with one count of distribution of a controlled substance, according to a 42-page criminal complaint released Wednesday.

Pettit and others allegedly distributed narcotics to Mac Miller — whose real name was Malcolm James McCormick — two days before he suffered a fatal drug overdose in Studio City, California, on September 7, 2018. The Los Angeles County Medical Examiner-Coroner later determined the rapper died of mixed drug toxicity involving fentanyl, cocaine and alcohol.

Get Breaking News Delivered to Your Inbox

"Fentanyl disguised as a genuine pharmaceutical is a killer — which is being proven every day in America," U.S. Attorney Nick Hanna said in a press release. "Drugs laced with cheap and potent fentanyl are increasingly common, and we owe it to the victims and their families to aggressively target the drug dealers that cause these overdose deaths."

Mac Miller performs October 28, 2017, in Los Angeles. Getty

Authorities said Miller died at age 26 after snorting counterfeit oxycodone pills containing fentanyl and that the pills had been provided by Pettit. While another individual allegedly supplied Miller with other drugs prior to his death, those narcotics drugs did not contain fentanyl, according to the criminal complaint.

The document also revealed Instagram messages Pettit sent to another user the night when news of Miller's death made headlines, where he allegedly wrote: "I am not great ... Most likely I will die in jail." Pettit goes on to write: "I'm gonna get off the grid. Move to another country."

In addition, investigators obtained text messages between Miller and Pettit in which they discussed the drug sale. Miller described his love for oxycodone, or "percs" for the brand name Percocet. He also asked for "bars" of Xanax and a "ball" of cocaine.

Pettit made an initial federal court appearance Wednesday in downtown Los Angeles. He wasn't asked to enter a plea, but he was ordered detained without bail pending trial and was given an October 11 arraignment date, according to CBS Los Angeles.

If convicted of the drug trafficking charge alleged in the complaint, Pettit will face a statutory maximum sentence of 20 years in federal prison.