Tunisia's parliament has adopted a law criminalising racist speech, incitement to hatred and discrimination, in a vote hailed as a historic first in a country with a significant black minority.

The legislation was approved on Tuesday night after a lengthy debate with 125 members of parliament voting for it, one against and five abstaining.

"This is a very important turning point in the history of Tunisia, equivalent to the abolition of slavery," said Messaoud Romdhani, head of the Tunisian Forum for Economic and Social Rights.

Slavery was abolished in the North African country when it was a beylik, or vassal of the Ottoman empire, in 1846.

"It's a giant step, but there's still a lot of work to be done to make this law a reality in a society where there is racism against the 10 percent of black Tunisians and sub-Saharan Africans who suffer from insults and sometimes violent attacks," said Romdhani.

While Saudi Arabia assassinates its journalists, #Tunisia passes the Arab world's first law criminalizing racism. Important step forward in one of the world's youngest democracies. https://t.co/DsFaRcpikg — Sharan Grewal (@sh_grewal) October 9, 2018

"It is a question of punishing but also of showing respect, especially through education."

Under the newly passed legislation, offenders can be jailed for one month and fined 1,000 dinars ($350) for using racist language.

Incitement to hatred, making racist threats, spreading and advocating racism, and belonging to an organisation that supports discrimination are punishable by one to three years in prison and can be fined up to 3,000 dinars.

"This is a historic moment for Tunisia," said the Tunisian Association for Minority Support, adding it would continue "the fight to ensure the proper implementation of the law".

Non-governmental organisations in Tunisia often report attacks on people singled out for the colour of their skin.

In August, an Ivorian woman was beaten after responding to insults, raising fears of more attacks on her community.