Nick Nolte, charged with driving under the influence of drugs, pleaded no contest before Malibu Judge Lawrence Mira on Thursday and was immediately sentenced to a $500 fine and three years’ probation, which includes counseling and drug testing, the Associated Press reports.

The jurist warned the actor, 61, that if any conditions of his parole are violated, then six months of jail will await him.

In exchange for his plea, prosecutors dropped a second misdemeanor charge of being under the influence of a controlled substance.

The actor was busted on Malibu’s Pacific Coast Highway last Sept. 11, when cops spotted his black 1992 Mercedes-Benz as it swerved into oncoming traffic. Subsequent lab tests revealed that Nolte was under the influence of the depressant GHB (gamma hydroxybutyrate) — also known as the “date-rape drug.”

Nolte — wearing a black suit and sporting a gray beard and long, gray slicked-back hair — said after his sentencing that he had taken “a synergistic amino acid thing.” Four days after his arrest, the “Prince of Tides” star voluntarily entered Silver Hill Hospital, a Connecticut rehab facility that has previously treated such stars as Billy Joel, Liza Minnelli and Mariah Carey.

“It was kind of a godsend, a wake-up call. I’ve been wanting to get out from under this substance because I have been sober from 1989 to 1999,” the actor told reporters after his court appearance.

During the hearing, Nolte was told by the judge, “I understand you are doing very well in this approach to rehabilitation. If there are any problems I will invite you to come back early (to court).”