Demi Lovato's near-death OD began at 4 AM July 24, when she texted a drug dealer to come to her house ... sources tell TMZ.
Sources with direct knowledge tell us, Demi had been at a party in WeHo following a birthday celebration at Saddle Ranch on the Sunset Strip. After the drug dealer got the text, he came to her house and we're told the 2 of them freebased Oxycodone on tin foil.
Our sources say unbeknownst to Demi, the drug dealer had a bad habit of buying dirty drugs from Mexico ... and the batch in question appeared to be laced with fentanyl -- that's the same drug that killed Prince and Lil Peep.
We're told the dealer fled her home when he noticed she was in bed, breathing very heavily.
Our sources say Demi had been using the dealer since April.