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

Law enforcement sources tell TMZ ... Mac was found Friday around noon in a bedroom at his San Fernando Valley home, and he was pronounced dead at the scene. 

CORONER LEAVING MAC'S HOUSE
TMZ.com

We're told authorities were alerted by a male friend who placed a 911 call from Mac's home. The emergency dispatch audio reveals first responders were called for a patient in cardiac arrest.

And there's this ... in a doc made a few years ago, Mac 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. You don't go down in history because you overdose. You just die."

Miller has battled substance abuse issues for years ... something that came up again 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.

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

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."

MAC AND ARIANA
TMZ.com

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."

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

EMERGENCY DISPATCH AUDIO

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."

MAC'S LAST POST TO INSTAGRAM

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 ... 

3:52 PM PT -- Mac's family has just released a statement on his death, saying, "Malcolm McCormick known and adored by fans as Mac Miller, has tragically passed away at the age of 26. He was a bright light in this world for his family, friends and fans. thank you for your prayers."

3:41 PM PT -- Mac's close friend and NBA All-Star Karl-Anthony Towns just showed up at Mac's home. Towns had tweeted, "Not only were you my favorite artist, you was one of my closest friends. The love we had was genuine and the moments we shared were filled with nothing but positivity and laughter."

Originally Published -- 1:20 PM PT