Mackenzie Phillips pleaded guilty to one count of felony cocaine possession in a Los Angeles court Friday, and agreed to enter an 18-month drug deferment program.
"I'd like to take this opportunity to thank [law enforcement] for stopping me, and probably saving my life," Phillips said to Judge Keith L. Schwartz.
As part of the program, if Phillips successfully completes her drug treatment, the entire case will be dismissed. The actress stated she's currently enrolled in a live-in treatment center in Louisiana.
"You're making tremendous progress [in rehab] and I'm proud of you," Judge Schwartz told Phillips. "This is a lifelong battle you're in."
Phillips was arrested
Aug. 27 for drug possession at Los Angeles International Airport. She was found "carrying what appeared to be heroin and cocaine in baggies and balloons," airport police said.
The former One Day at a Time
star was formally charged with two felonies, for possession of heroin and cocaine, as well as a misdemeanor charge of unauthorized possession of a hypodermic needle or syringe.
The actress, 48, has long struggled with drug addiction – making multiple trips to rehab – stemming back to her youth while starring on the '70s sitcom.
1994: Mackenzie Phillips plays a drug counselor on 90210
1981: Phillips and her dad kick their $1 million drug habit
Mackenzie's first PEOPLE cover