Mac Miller performs on his Space Migration Tour in Philadelphia. Picture: AP

Mac Miller's alleged drug dealer has been charged with selling counterfeit drugs to the late rapper.

The "Self Care" hitmaker died from an overdose on 7 September 2018 and almost a year later, the Drug Enforcement Administration's Fusion Task Force have arrested 23-year-old Cameron James Pettit, alleging that he sold counterfeit drugs containing fentanyl to the late rapper.

According to an affidavit in support of the complaint, Pettit is alleged to have taken counterfeit oxycodone pills which contained the opioid fentanyl, as well as cocaine and Xanax to Mac - whose real name was Malcolm McCormick - two days before his death.

Mac's death was found to be an accident and it was later determined he had overdosed on alcohol, cocaine and fentanyl, with investigators believing he passed away after snorting the fake pills.

If convicted, Pettit would face a minimum sentence of 20 years in federal prison for drug trafficking and it seems he has been aware of the possible punishment for some time.

According to the affidavit, after reports of Mac's death were published, the man allegedly sent an Instagram message to a friend which read: "Most likely I will die in jail...

"I'm gonna get off the grid. Move to another country."

Investigators also had text messages between Pettit and Mac, in which the rapper asked for "bars" of Xanax and a "ball" of cocaine.

Before his death, Mac admitted he never wanted to overdose because there was nothing "cool" about it.

He said: "I'd rather be the corny white rapper than the drugged-out mess who can't even get out of his house. Overdosing is just not cool.

"There's no legendary romance, you don't go down in history because you overdosed. You just die."

The "Dang!" rapper was also candid about his drug abuse and problems with depression.

He said: "I had a drug problem for a long time.

"It wasn't just in music, but I definitely was going through a drug problem and I think it was more my state of mind. I was just pretty depressed."