The Los Angeles County Department of Medical Examiner - Coroner confirmed the star's cause of death on Monday.
The 26-year-old, who rose to fame after topping US charts with his debut album in 2011, was found dead at his California home in September.
Ex-girlfriend Ariana Grande called him "an angel" in a song at the weekend.
Ariana Grande addresses ex-boyfriends
Mac Miller tribute gig held in Los Angeles
Chance the Rapper, SZA and Miguel were among the artists to perform at a tribute concert at the weekend.
Fentanyl, a powerful painkiller that tends to be cheaper and more potent than heroin, has played a major part in the USA's opioid crisis.
An estimated 200 people die of overdoses every day, according to the US Drug Enforcement Administration.
The singer Prince had taken fentanyl before his death in 2016.
The drug was also a factor in the fatal overdose suffered by rapper Lil Peep in November 2017.