Sly Stone could get off scot-free on cocaine charges ... because he's copped a plea that will keep him out of jail.
Under the deal, Sly, who has already put in 30 days of in-patient rehab, must complete an additional 60 days.
As we first reported, the 68-year-old "Family Stone" singer was arrested on April 1 after cops say Stone was carrying freebase cocaine.
Stone pled no contest in court today and the judge imposed the sentence. If Stone completes his rehab on time, the judge will dismiss the case outright and there will be no probation.
Sly's lawyers James E. Silverstein and Peter Knecht tell TMZ, "We are very pleased with the outcome of this case."