TUNIS, Tunisia - The Islamic State 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 extremist cells were 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 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-Qaeda'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, ISIS 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 neighboring and chaotic Libya have pledged their allegiance to the 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 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 radicals, 500 have returned.

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.

President Obama spoke with Tunisian President Beji Caid Essebsi by phone to offer his condolences, sympathy, and support.

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.

In the afternoon, authorities opened the gates of the museum for a rally. About 500 people - some carrying flowers for the victims - held a moment of silence before singing Tunisia's national anthem. Participants included black-robed lawyers, families with children, and teenagers swathed in the red-and-white Tunisian flag.

A funeral was held for Aymen Morjen - an elite member of Tunisia's security force who was killed at the museum.

A Spanish man and a pregnant Spanish woman who survived the attack hid in the museum all night in fear. Spain's foreign minister said police searched all night before Juan Carlos Sanchez and Cristina Rubio were found Thursday morning.

The Health Ministry said the death toll rose to 21 on Thursday - 20 of them foreign tourists. Nearly 50 people were wounded.

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 Spaniards who died were celebrating their 50th wedding anniversary, and it was the first time they had traveled outside Spain, the Spanish foreign minister said. Their children were flying to Tunis to retrieve the bodies.