Tunisia said two gunmen who killed 21 people at its national museum trained at a militant camp in Libya, as the country marked its Independence Day in sombre fashion Friday.
The Islamic State jihadist group has claimed Wednesday's attack on foreign tourists in Tunis, the deadliest since Tunisia's 2011 revolution which sparked the Arab Spring regional uprisings.
The two assailants "left the country illegally last December for Libya and they were able to train with weapons there," Secretary of State for Security Rafik Chelly told Tunisian television.
IS, which has hundreds of Tunisians among its ranks, threatened more attacks in an audio message posted online Thursday claiming responsibility for the museum massacre.
Authorities say as many as 3,000 Tunisians have gone to Iraq, Syria and Libya to fight in jihadist ranks, raising fears of battle-hardened militants returning home to plot attacks.
Chelly named locations of several suspected training camps for Tunisians in violence-wracked Libya, including the second city Benghazi and the coastal town of Derna, which has become a stronghold for jihadists.
The president's office said security forces arrested nine suspects -- "four people directly linked to the (terrorist) operation and five suspected of having ties to the cell".
And a presidential source said soldiers were to be deployed in major cities following the assault, while insisting "we are not under siege".
As international outrage grew over the attack on Tunisia -- hailed as a rare success story of the Arab Spring -- President Beji Caid Essebsi said his country would not be cowed by extremism.
"The process of implementing a democratic system is underway, well anchored," he told France's TF1 television. "We will never move backwards."
Essebsi was set to make a speech Friday to mark the anniversary of Tunisia's independence from France in 1956, though celebrations were dimmed after Wednesday's carnage.
Marches against extremism were planned on Friday in Tunis and the southern tourist hub of Djerba.
Local media was also defiant, with the daily La Presse's front page declaring: "Tunisia will overcome" and the Assasbah newspaper running the headline: "The Second Republic will prevail".
The dead included four Italians, three Japanese, three French, two Spaniards, a Colombian, an Australian-Colombian, a British woman, a Belgian woman, and a Pole, health ministry officials said.
A Tunisian policeman killed in the attack was buried on Thursday. Three victims have yet to be identified.
Dozens more people were wounded in the assault, in a massive blow to Tunisia's heavily tourism-dependent economy.
At least two major cruise ship operators suspended stopovers in Tunis following the attack.
The government, in a show of defiance, said the National Bardo Museum would reopen early next week.
Prime Minister Habib Essid named the two gunmen killed by security forces at the museum as Yassine Abidi and Hatem Khachnaoui.
Chelly said Abidi had been arrested before making his way to Libya, and that the pair had been "from sleeper cells" present in several areas.
President Essebsi said the gunmen had explosives on them and he praised the security forces for preventing further bloodshed.
Tunisia has seen an upsurge in Islamist extremism since the 2011 revolution that ousted longtime strongman Zine El Abidine Ben Ali and sparked the Arab Spring uprisings around the region.
US President Barack Obama called Essebsi to offer condolences and assistance with the investigation as world leaders denounced the attack.
Palestinian Islamist movement Hamas described the shooting as "a crime against humanity".
A retired Colombian general whose wife and son, a dual Colombian-Australian national, were killed, lamented the "irony" of losing them on holiday after spending his life "fighting terrorism" at home.
"Look at the irony of life, all my life I spent in the military fighting terrorism, combating terrorism, and now in a place totally remote from Colombia it takes my wife and son," Jose Arturo Camelo said, according to the Colombian president who called him.
Tunisia has taken pride in forming a democratic government and achieving stability since the Arab Spring.
But dozens of police and military personnel have been killed or wounded in attacks blamed on Islamist militants.
*This story has been edited by Ahram Online