Pop star Justin Bieber pleaded guilty to lesser charges on Wednesday to resolve a criminal case brought by Miami Beach police who initially said he was caught drag racing in a Lamborghini under the influence of alcohol and drugs.

The agreement with prosecutors requires the Canadian singer, who was not in court, to attend a 12-hour anger-management class, watch online videos about tragic drunken driving cases and donate $50,000 to a children's charity.

As part of the deal, Bieber pleaded guilty to careless driving, a civil infraction, and resisting an officer without violence, a misdemeanor. In return, the state dropped a charge of driving under the influence.

In approving the plea deal, Miami-Dade Circuit Judge William Altfield said he hoped Bieber, 20, was aware that his actions had consequences due to his status as a celebrity and a role model for young people.

"While this is a case that involved driving under the influence, he (Bieber) needs to be cognizant of the fact that there are many young persons who are living under the influence, and he is the influence," Altfield said.

"Here is someone who is young, his whole life is ahead of him. He just hopefully will get the message, he will grow up, he will use all of his talents positively for younger persons," he added.

Bieber's attorneys said they would deliver the judge's message to their client. "We'll turn this into a positive experience ... and we'll make sure this becomes a positive experience for everyone," said one of his lawyers, Howard Srebnick.

Bieber, who frequently makes headlines due to his party-intense lifestyle, initially was charged with driving under the influence, resisting arrest and using an expired license after police stopped and arrested him while he was driving a rented yellow Lamborghini the morning of Jan. 23.

The singer, whose hit songs include "Boyfriend," was not given any special treatment by being allowed to plead in absentia, the judge said.

Police said at the time of Bieber's arrest that two SUVs had blocked off the road so the singer could race a friend. Bieber cursed at police officers and later told them he had consumed alcohol, marijuana and prescription drugs, according to the arrest report.

A drug test found marijuana and prescription anti-anxiety medication in his system at the time of the arrest, according to a toxicology report.