Paris Hilton has admitted having cocaine in her handbag and pleaded guilty to two minor charges after her arrest last month in Las Vegas.
She will serve a year of probation and avoid a more serious felony charge under a plea deal worked out with prosecutors.
The celebrity heiress pleaded guilty to drug possession and obstructing a police officer.
Hilton, 29, must complete a drug abuse program, pay a 2,000 dollar fine (£1,300) and serve 200 hours of community service.
Hilton - wearing a champagne-coloured blouse, a black pencil skirt and black platform heels - told Judge Joseph Bonventure in the Las Vegas court she had been in possession of cocaine.
When he asked what she did to obstruct justice, Hilton, swaying side to side, responded, "I said that the purse (handbag) wasn't mine to the officer," and acknowledged that she had bought it months earlier.
When asked why she didn't fight the charge, her lawyer, David Chesnoff said, "Miss Hilton accepts the responsibility."
She faces a year in jail if she breaks the probation and is arrested for anything other than a minor traffic violation.
Judge Bonventure told Hilton she would have to stay out of trouble.
"I assure you the Clark County Detention Centre is not the Waldorf Astoria," he told her.