Tunisian rapper Ala Yaacoub has been sentenced to two years in prison for insulting and threatening the police.
Police clashed with his supporters outside the court in the capital, Tunis, with three of them arrested, AFP news agency reports.
Known to his fans as "Weld El 15", he had posted a song, The Police are Dogs, on the internet.
Yaacoub emerged from hiding for his one-day re-trial after being given the same sentence in absentia in March.
He turned himself in in the hope of receiving a more lenient sentence, reports the BBC's Sihem Hassaini from Tunis.
'Tear gas fired'
The video's director, Mohamed Hedi Belgueyed, and actress Sabrine Klibi, who featured in it, had been given a suspended sentence of six months each during their trial in March, our correspondent says.
Yaacoub's lawyer Ghazi Mrabet described the sentence as "very tough for an artist who decided of his own accord to face justice", AFP reports.
In the song, Yaacoub called the police dogs who "should be slaughtered instead of sheep on Eid al-Adha [a Muslim festival]", our correspondent says.
She adds that Yaacoub was not a popular performer in Tunisia, but received a lot of support from journalists and bloggers after he was charged.
As the judge read out the verdict, shouts of protest erupted in the courtroom from his supporters who were evicted by police.
Several people were beaten outside the building, including Emine M'tiraoui, a journalist with the news blog Nawaat, and at least three people were arrested, the AFP news agency reports.
Tear gas was fired, but it was not clear who was responsible, said the agency.
Police and friends of the singer blamed each other for firing it, it adds.
Before his trial, Yaacoub told AFP that the Tunisian authorities were not respecting freedom of speech.
"I am afraid because in a country like Tunisia the law is not applied; you can expect anything," he is quoted as saying.
"In the song, I used the same terms that the police used to speak about the youth. The police have to respect citizens if they want to be respected," he added.
He faced a wide range of charges, including insulting policemen and conspiracy to commit violence against them.
Tunisia elected a moderate Islamist-led government after the overthrow of long-serving ruler Zine al-Abidine Ben Ali in 2011.
It was the first country to be hit by the "Arab Spring", as people demanded an end to political repression and greater freedom.
There has since been an increase in the prominence of ultra-conservative Islamists known as Salafists, who campaign for greater public piety in Tunisia.
On Wednesday, a court in Tunis sentenced three European feminists to four months in prison for staging a topless protest.
A judge convicted the two French women and a German woman after they were charged with public indecency.
The women were part of the Ukrainian feminist group Femen, which staged its first such protest in the Arab world.
They were arrested after protesting for the release of fellow activist Amina Tyler, who has been charged with carrying an "incendiary object" in May.