Mauritanian President Mohamed Ould Abdel Aziz on Wednesday called for the west African country to root out hate speech as he headed a rally aimed at dampening ethnic tensions.

"The people who are behind this speech are a minority, but we have to put an end to their toxic behaviour for the sake of the future," the president said at the march in the capital, Nouakchott.

It is the first rally led by President Aziz since he came to power in a coup in 2008. He added during the march that he would use a law adopted last year to crack down on "hateful, racist or violent speech".

On January 1, government Spokesperson Sidi Mohamed Ould Mouhamed cited what he described as "a recent escalation of hate speech and attempts to sow hatred among the Mauritanian people".

Aziz called for the gathering in response to ongoing combative disputes on social media, including Whatsapp, between the country's Arab-Berber community and the Haratines, former slaves and their descendants.

Marchers carried banners promoting ethnic cohesion and chanted "no to hate, no to extremism and inciting violence". According to organisers, the march was attended by hundreds of thousands of Mauritanians who were given the day off with pay to attend the rally.

Mauritania, a desert country with a population of around 4.4 million, was the last nation to abolish slavery in 1981 and it introduced the first law to punish slave-owning in 2007.

However, according to activists the practice still remains entrenched in the country.

Human rights groups, particularly the Initiative for the Resurgence of the Abolitionist Movement (IRA-Mauritania), denounce the persistence of slavery and the condition of dire poverty of former slaves and their descendants.

The president stated that he recognised the country had "social and economic disparities, like everywhere in the world where there are rich and poor," but the "remedy for this lies in education".

The opposition declined an invitation to the rally, saying "this march cannot be a solution" to the problems justifying it and calling for a national dialogue to find "sustainable solutions".