Mac Miller died Friday of an apparent overdose … TMZ has learned.

Law enforcement sources tell TMZ … Mac was found Friday at around noon at his San Fernando Valley home and was pronounced dead at the scene.

We’re told authorities were alerted by a male friend who placed a 911 call from Mac’s home.

Miller has battled substance abuse issues for years … something that came up in the wake of his breakup with Ariana Grande. The rapper wrecked his G-Wagon by wrapping it around a utility pole back in May and was arrested for DUI and hit and run. He fled the scene but cops say he later confessed at his home. He blew 2 times the legal limit.

After his arrest Ariana tweeted, “Pls take care of yourself” and was clearly concerned about substance abuse.

Some people blamed Ariana for Mac’s DUI, and she responded, “I am not a babysitter or a mother and no woman should feel that they need to be. I have cared for him and tried to support his sobriety & prayed for his balance for years.” She added, “Of course I didn’t share about how hard or scary it was while it was happening but it was.”

Sources close to Mac tell TMZ, friends of his warned people not to bring up the subject of his relationship with Ariana because it was “too touchy.”

After their breakup, Ariana made it clear … his substance abuse had been a deal breaker in their 2-year relationship.

His 2014 mixtape, “Faces,” was almost autobiographical on the subject of drug use. There were also references to premature death.

A profile of Mac was just published Thursday by Vulture — among other things, Mac said he had enormous pressure growing up in the public eye … “A lot of times in my life I’ve put this pressure to hold myself to the standard of whatever I thought I was supposed to be, or how I was supposed to be perceived. And it creates pressure.”

Thursday night Mac posted video of a record player and you hear his song, “So it Goes,” which includes lyrics, “Nine lives, never, die, f*** a heaven, I’m still gettin’ high.”

Mac was supposed to start a tour next month.

Story developing …