In a blog post Mahathir, 95, a respected leader in the Muslim world, said he believed in freedom of expression but that it should not be used to insult others.
"Muslims have a right to be angry and to kill millions of French people for the massacres of the past. But by and large the Muslims have not applied the 'eye for an eye' law. Muslims don't. The French shouldn't," Mahathir said in a blog post, which he also posted on Twitter.
"Since you have blamed all Muslims and the Muslims' religion for what was done by one angry person, the Muslims have a right to punish the French," he said.
Twitter said the message violated its rules about glorifying violence, but it determined that it may be in the public's interest for the post to remain.
Several Muslim-majority countries have denounced remarks by French officials, including President Emmanuel Macron, defending the use of cartoons of the Prophet Mohammad in a French school classroom. The caricatures are seen as blasphemous by Muslims.
The dispute flared after a French teacher who showed his pupils satirical cartoons of the Prophet during a civics lesson was later beheaded in the street by an attacker of Chechen origin.French officials said the killing was an attack on the core French value of freedom of expression and defended the right to publish the cartoons. Macron has also said he would redouble efforts to stop conservative Islamic beliefs subverting French values.