A Moroccan rapper who has become one of the monarchy's boldest critics was freed on Thursday, activists said, after he served a four-month sentence for assault, a charge which his lawyers say was a ploy to muzzle the popular singer.

El-Haqed walked out of prison a little while ago shouting 'long live the people', said activist Omar Radi, near Casablanca's main Oukacha prison.

Earlier on Thursday, a court in Casablanca sentenced 24-year-old Mouad Belrhouat, better known as El-Haqed (The Sullen One), to four months and three days in jail and fined him 500 dirhams ($57), sources in the court said.

Belrhouat was arrested in September after a brawl with a monarchist. Bail requests by his lawyers were rejected and the trial was adjourned six times.

It's a bittersweet victory for us, said activist Maria Karim.

El-Haqed has become the singing voice of the protest movement, inspired by Arab world uprisings, demanding a constitutional monarchy, an independent judiciary and a crackdown on corruption.

Morocco's main human rights group, AMDH, considers him to have been a prisoner of conscience.

His lyrics telling Moroccans to wise up have angered many monarchists. In one song, he says the king spends so much time giving orders that he has little time to count his money in Switzerland.

Belrhouat has struck a chord with young Moroccans who are disenchanted with the lack of jobs and one song Bite just as much as you can chew has had more than 600,000 hits on YouTube.

($1 = 8.7220 Moroccan dirhams)

(Reporting by Souhail Karam; Editing by Louise Ireland)