The Casablanca-born rapper, whose real name is Taha Fahssi and who is a massive star in the Arabic-speaking music world, told reporters after one of his concerts, "I smoke hash -- so what?... It doesn't mean I set a bad example."
That sparked anger in conservative Morocco, where recreational use of the drug is illegal despite the country being the world's top producer, according to the United Nations.
On Monday, a Casablanca prosecutor ordered the musician detained after complaints were filed by three artists, a journalist, and a policeman.
But on Wednesday he was released after those complaints were withdrawn, the judicial source told AFP.
He also paid a 20,000-dirham ($1,845) fine and apologised again for his comments, the source said, adding that he remained under investigation for alleged "insults, defamation and threats".
The rapper had already apologized at a packed press conference in Rabat on Sunday.
Moroccan media say he remains under investigation for social media posts and public statements that may "contain elements punishable by law."