LOS ANGELES, (Reuters) - Aaron Sorkin, creator of the hit NBC series ``The West Wing,'' agreed Tuesday to enter a court-supervised drug treatment program that spares him a felony conviction and jail time for drug possession. The Emmy award-winning producer, who in 1999 acknowledged being treated for drug addiction, was arrested on April 15 at an airport in suburban Burbank after security staff found what authorities said were hallucinogenic mushrooms, rock cocaine and marijuana in a carry-on bag. He pleaded not guilty last month to drug possession charges stemming from the arrest. But to gain admission to the ``Deferred Entry of Judgment'' program, Sorkin entered a guilty plea to two felony counts and a misdemeanor during a court hearing in Burbank Superior Court. No judgment against him will be entered and the case will be dismissed if he successfully completes the court-supervised treatment program which can last up to two years, Sandi Gibbons, a spokeswoman for the Los Angeles County District Attorney's Office, said. If he fails to adhere to the program, Sorkin is subject to three years and eight months in prison plus a fine of up to $10,000, she said. Particulars of the treatment will be worked out with Sorkin's probation officer, but the program mainly involves drug counseling and testing, Gibbons said. The producer is not required to live at a rehabilitation facility. While a statement from Sorkin's publicist said the program would last 18 months, Gibbons said the program was set by the judge to run 24 months but could be shortened in the future. ``Needless to say, it is a relief to have a resolution regarding my legal situation,'' Sorkin said in a statement. ``I fully intend to proceed as directed by the court and am eager to get back to work and focus on what's important. ``In addition, I would like to thank my family, friends and colleagues for the tremendous amount of support and encouragement they have provided during this period,'' he said. Sorkin, the creator and executive producer of the Emmy-winning White House series ``The West Wing,'' told the Los Angeles Times in a 1999 interview that he had previously been treated for an addiction to freebase cocaine. ``I'm the same as any other addict. I'm only a phone call away from getting loaded again,'' he was quoted as saying then. Sorkin's feature credits include screenplays for the 1992 court-martial drama ``A Few Good Men,'' starring Tom Cruise, Jack Nicholson and Demi Moore, and 1995' ``The American President,'' starring Michael Douglas and Annette Bening.