Updated

Tunisian rapper Ala Yaacoubi, jailed for two years last month for a song in which he insulted the police, will be freed on Tuesday after being given a six month suspended sentence on appeal, his lawyer said.

"It's a victory for freedom and democracy, for Weld El 15 who did nothing wrong but made a work of art," attorney Ghazi Mrabet, who used the singer's rap name, said following the court's verdict.

As the ruling was announced, shouts of joy erupted outside of the court of appeal in Tunis where friends and supporters of the rapper had gathered.

"Freedom for Weld El 15!" they shouted.

The 25-year-old musician was to be freed from the prison in a suburb of the capital where he has been held since his conviction by the court of first instance on June 13.

The severity of the initial two-year jail sentence, for a song he wrote called "The Police are Dogs," in which he aggressively insulted Tunisian police and judges, was sharply criticised even by some government officials.

Members of the opposition and human rights groups called it an attack on freedom of speech, a charge rejected by Islamist Prime Minister Ali Larayedh.

"He was not tried on the basis of his work, or the freedom of expression, but for inciting hatred and calling for the death of police and magistrates," Larayedh said on Monday, in an interview with television channel France 24.

In the video of the song which was posted on YouTube, the rapper is heard saying: "Police, magistrates, I'm here to tell you one thing, you dogs; I'll kill police instead of sheep; Give me a gun I'll shoot them."

Tunisia's Islamist-led government has frequently been accused by its critics of seeking to curb civil liberties acquired after the popular uprising that overthrew former strongman Zine El Abidine Ben Ali in January 2011.