Tunisia forces killed have nine Islamist militants, including a top commander, just hours before world leaders were due to march in Tunis in solidarity after an attack on the Bardo museum this month.

French President Francois Hollande joined thousands of Tunisians on the march, after the attack nearly two weeks ago, in which 24 people died, including 21 tourists, two militants and a Tunisian policeman.

Tunisia's Prime Minister Habib Essid said the raid in the southern Gafsa region killed nine militants from the local group Okba Ibn Nafaa, including an Algerian militant Lokman Abu Sakhr, accused of helping orchestrate Bardo.

"We have killed most of the leaders of Okba Ibn Nafaa who were behind many recent attacks," Mr Essid said.

"This is a clear and strong response to the terrorism after the Bardo attack."

Thousands of police and soldiers were positioned around the capital before the "Le Monde est Bardo" protest along a main boulevard leading to the museum known for its collection of Roman mosaics.

The killing spree at the Bardo was one of the worst attacks in Tunisia's history. The North African country has mostly avoided violence since its 2011 uprising against autocrat Zine El-Abidine Ben Ali and has been praised by the international community as a model of democratic transition with a politics of compromise, a new constitution and free elections.

A fourth French national died of her wounds following the March 18 attack.

Japanese, Polish, Spanish and Colombian tourists were among those killed in the attack that the government says was aimed at destroying Tunisia's vital tourism industry, which makes up around seven percent of its economy.

Islamic State (IS) claimed the Bardo attack though the Tunisian government has said the Okba Ibn Nafaa group, which has a base in the Chaambi mountains bordering Algeria, was involved.

That group was previously more allied to al Qaeda in the Islamic Maghreb, but it has also made vague statements on its position toward IS.

The Bardo attack underscored how Islamist militant loyalties are blurring as they seek a new North African front, especially in Libya, where political chaos and factional fighting has allowed IS to gain an outpost.