Danilo Gentili, a conservative known for his aggressive attacks on the left, was tried over a 2017 clip he shared on social media

A row over free speech has erupted in Brazil after a foul-mouthed conservative comedian was given a six-month jail sentence for abusing a leftwing politician.

Known for his aggressive attacks on the Brazilian left, Danilo Gentili, 39, was sentenced by a judge in São Paulo on Tuesday for his comments about Maria do Rosário, a congresswoman for the southern state of Rio Grande do Sul. He remains free pending appeal.

Gentili was tried over a 2017 video he shared on social media, in which he ripped up a notice he had been sent by the Brazilian congress asking him to remove offensive tweets about Do Rosário, stuffed it into his underpants and directed obscenities at her.

Woman who Bolsonaro insulted: 'Our president-elect encourages rape' Read more

In her ruling, Judge Maria do Prado wrote he could have removed the tweets or taken legal advice. Instead, he “decided to record a video with highly offensive and reproachable content, leaving very clear your intention to offend”.

Do Rosário has often been a target for attacks from the Brazilian right. In February, Brazil’s supreme court upheld a ruling that Jair Bolsonaro pay her about £3,000 ($3,920) in damages for telling her she “did not deserve” to be raped in 2014.

On Tuesday, Bolsonaro was criticized for expressing solidarity with Gentili, despite failing to do so for the family of a Rio man who was killed earlier in the week when soldiers fired 80 bullets into his car.

Do Rosário welcomed Tuesday’s verdict in a series of tweets. “Impunity can’t prevail in any way when you are dealing with people’s honour,” she said, while the Workers’ party president, Gleisi Hoffmann, tweeted clapping hands.

But the leftist blog O Cafezinho (the Little Coffee) called the verdict “mistaken”, saying: “Today it’s Danilo Gentili, a humourist hated by the left. Tomorrow it could be anyone who said some tough words against the Bolsonaro family.”

Gentili – who once shared a positive tweet about fascism and linked the leftwing Socialism and Freedom party to paedophiles in a standup show – tried to laugh off the sentence. “I’m worried about who will bring me a cellphone in prison, who will bring cigarettes,” he told the Jovem Pan radio station.

“I prefer to be jailed than kneel down,” he said. “I don’t think I did anything wrong.”