A judge in Nevada made the ruling after lawyers for the Grammy-winning star said he had stayed out of trouble and met other conditions of a plea deal reached almost a year ago.
The 26-year-old singer-songwriter of hits including Just The Way You Are did not appear in person in Clark County District Court in Las Vegas.
His real name is Peter Gene Hernandez.
He pleaded guilty on February 16.
Judge Jessie Walsh agreed he completed probation, paid a $2,000 (€1,556) fine and performed 200 hours of community service and eight hours of drug counselling.
Mars acknowledged having 2.6 grammes of cocaine when he was arrested in September 2010 after a performance at the Hard Rock Hotel and& Casino in Las Vegas.