You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
He was found unresponsive at his home in the Studio City neighbourhood on Friday and pronounced dead there, the Los Angeles County Coroner's Office said in a statement.
Celebrity website TMZ reported that Miller died in Los Angeles of an apparent drug overdose but Reuters could not confirm that.
Miller, whose real name was Malcolm McCormick, had discussed his use of drugs in media interviews and rap lyrics.
The coroner's office did not release the cause of death, saying a post-mortem would be carried out.
In a statement, Miller's family confirmed the death, calling him "a bright light in this world for his family, friends and fans.
Miller first gained a following at 18 with his mixtape K.I.D.S. in 2010. His best known songs include Loud, Smile Back, and a collaboration with Grande called The Way.
Rapper Wiz Khalifa, who like Miller grew up in Pittsburgh and was close to him, tweeted on Friday: "Praying for Mac's family and that he rest easy."
Miller dated Grande from 2016 until earlier this year, according to media reports.
In May, he was arrested in Los Angeles in connection with a car crash and was later charged with driving under the influence.
Grande, after a Twitter user appeared to blame her for the break-up, wrote on the social media platform in May that the relationship was "toxic" and she had "cared for him and tried to support his sobriety & prayed for his balance for years."
Miller's most commercially successful album was his 2011 Blue Side Park which topped the charts. This year, his release Swimming hit No 3 on the Billboard 200 list of top albums.
He was scheduled to launch a US tour next month, and had tweeted about it on Thursday. "I wish it started tomorrow," he wrote.