CARACAS, Venezuela — Venezuela’s all-powerful constitutional assembly passed a wide-reaching law on Wednesday that clamps down on social media and broadcasters alike by ordering prison sentences of up to 20 years for anyone who instigates hate.

The pro-government assembly passed the law, accompanied by rousing applause and flag-waving on the chamber floor. It prohibits Venezuelans from spreading any message through television, radio or social media that instigates violence or hate.

It drew swift criticism from international human rights advocates, who say the new law cracks down on dissent by criminalizing peaceful protests, the hallmark of a democratic society.

“The law seeks to end free speech in social media — a key space for Venezuelans to express themselves in a country with shrinking free speech avenues,” said Jose Miguel Vivanco of the New York-based Human Rights Watch.

Backers of socialist Nicolas Maduro have often accused opponents of being fascists spreading hateful messages.

The law also targets political parties that promote “fascism, intolerance or national hate,” prohibiting them from registering with the government-stacked National Electoral Council. That appears aimed at opposition parties that claim council officials committed fraud in recent regional elections handily won by pro-government candidates.

Opposition party leaders have vowed not to participate in upcoming municipal elections.

The law requires administrators of social media accounts to immediately remove any hateful posts. It also calls for the creation of a commission to enforce the anti-hate law, which carries punishments of 10 to 20 years in prison.

The new pro-government constitutional assembly was installed in August and given virtually unlimited powers. Many foreign governments consider the assembly illegitimate.

Constitutional assembly president Delcy Rodriguez, who oversaw the law’s passage, defended it as sending a strong message to anybody wanting to promote war. Rather, they should spread of “messages of peace,” she said.

“This is a law that promotes peaceful coexistence,” she said. “Something that the world needs precisely in these moments when the imperial powers threaten with more war.”