Rwanda's Supreme Court has upheld a law that says defaming the president is illegal, but it says drawing cartoons or producing writing that "humiliates" a government official is no longer a crime.

The Rwanda Journalists Association had challenged parts of the penal code that criminalized the publishing of such cartoons with punishment of up to four years in prison.

A three-judge panel decided the provisions contravene freedom of expression.

The association's executive secretary, Gonza Muganwa, welcomed the ruling, telling The Associated Press it removes a major obstacle to press freedom in the East African nation.

Defaming the president remains illegal, with a punishment of five to seven years in prison and a fine.