Mars will avoid prosecution if he stays out of trouble for the next year, gets eight hours of drug counseling, does 200 hours of community service and pays a $2,000 fine, according to terms of a deal accepted in court Wednesday.

The 25-year-old was arrested in a casino restroom last September, allegedly with 2.6 grams of cocaine in the left front pocket of his jeans, police said.

The resolution of the singer's legal trouble comes three days after Mars won a Grammy for best male pop vocal performance and received a standing ovation for his onstage Grammy performance with Janelle Monae.

Mars and Monae announced Wednesday they will start touring the United States together in May.

Under the "deferred adjudication" agreement of the felony drug charge, the district attorney will not pursue the charge for 12 months as long as Mars complies with terms of their deal, Berk said. After a year, the charge would be dropped.

Mars, whose real name is Peter Hernandez, was riding high on the music charts when he was arrested last year.

His single, "Just the Way You Are," shot to No. 1 on the Billboard Hot 100 chart that month. His latest single, "Grenade," is currently at the top of the charts.