The Islamic State group claimed responsibility Thursday for the attack that killed 21 people at a museum. But Tunisian authorities said the two slain gunmen had no clear links to extremists, and analysts said existing militant cells are merely being inspired by the group, rather than establishing its presence across North Africa.

Police announced the arrest of five people described as directly tied to the two gunmen who opened fire Wednesday at the National Bardo Museum. Four others said to be supporters of the cell also were arrested in central Tunisia, not far from where a group claiming allegiance to al-Qaida's North African branch has been active.

Tunisians stepped around trails of blood and broken glass outside the museum to rally in solidarity with the 21 victims — most of them foreign tourists from cruise ships — and with the country's fledgling democracy. Marchers carried signs saying, "No to terrorism," and "Tunisia is bloodied but still standing."

In claiming responsibility for the attack, the Islamic State group issued a statement and audio on jihadi websites applauding the dead gunmen as "knights" for their "blessed invasion of one of the dens of infidels and vice in Muslim Tunisia."

Several well-armed groups in neighbouring and chaotic Libya have already pledged their allegiance to Islamic State based in Iraq and Syria, but the attack of such magnitude in Tunisia — the only country to emerge from the Arab Spring uprisings with a functioning democracy — raised concern about the spread of extremism to the rest of North Africa.

Analysts cautioned against seeing every such attack as evidence of a well-organized, centrally controlled entity spanning the Middle East, saying instead that small groups could merely be taking inspiration from the high-profile militant group.

"I think (the Islamic State) is probably taking credit for something it may not have played a role in," said Geoff Porter, a security analyst for North Africa.

Confronted with a poor economy, young Tunisians have disproportionately gone abroad to fight with extremist groups in Libya, Syria and Iraq, including some affiliated with the Islamic State. Upon their return home, some may have decided to carry out attacks on their own.

Tunisian authorities have estimated that of the 3,000 young people who left the country to fight with radical groups, about 500 have returned.

"It could have been people who fought with the Islamic State or were inspired by it," said Raffaello Pantucci, director of International Security Studies at the Royal United Services Institute, a British think tank. "Some guys may have come back, not liked what the government is doing, and attacked the tourist industry to hurt the economy — a classic move."

Until now, Tunisia's most deadly group was the Oqba Ibn Nafaa brigade, which is allied to al-Qaida and based in the mountains near the Algerian border. Previously, it has confined its attacks to political figures and security services.

"While Tunisia's ultra-radical Islamist fringe was most associated with al-Qaida, there is no reason why the jihadi underground shouldn't have changed its tutelage," said Jon Marks, associate fellow at Chatham House, a London think tank. "However, whether this `rebranding' goes as far as direct command and compliance structures is far from clear."

At a news conference Thursday, Prime Minister Habib Essid announced new security measures around the country, including a crackdown on websites seen as promoting terrorism.

The deaths of so many foreigners will damage Tunisia's tourism industry, which draws thousands of foreigners to its Mediterranean beaches, desert oases and ancient Roman ruins. The industry had just started to recover after years of decline.

Two cruise ships that had 17 passengers among the dead quickly left the port of Tunis early Thursday, citing safety concerns, and the vessels' operators suspended visits to the country.

Culture Minister Latifa Lakhdar gave a defiant news conference at the museum, where blood still stained the floor amid the Roman-era mosaics.

"They are targeting knowledge. They are targeting science. They are targeting reason. They are targeting history. They are targeting memory, because all these things mean nothing in their eyes," she told reporters.

The Health Ministry said the death toll rose to 23 on Thursday — 20 of them foreign tourists. Nearly 50 people were wounded. Three Tunisians were killed, including the two attackers.

Dr. Samar Samoud of the Health Ministry said six of the dead foreigners remained unidentified. She listed the rest of the foreign victims as three from Japan, three from France, two from Spain, and one each from Australia, Colombia, Britain, Poland, Belgium and Italy.

The Costa Crociere cruise line said four Italians and a Russian were among the dead. It was not immediately clear whether they were the victims not yet identified by the ministry. MSC Cruises said 12 of its guests were killed.

The two cruise lines said they suspended visits to Tunisian following the attack.