The Islamic State said Thursday that two of its fighters had carried out the attack on a museum here that killed 20 foreign tourists, a rampage that raised fears of the jihadist group’s growing international footprint.

In an audio recording distributed online, the Islamic State said the two gunmen, both said to be Tunisians, struck “citizens of the Crusader countries” in the attack Wednesday, according to a translation by the SITE Intelligence Group.

The statement marked the first time the Islamic State has claimed an operation in the North African nation, although the group boasts thousands of Tunisian fighters among its ranks in Iraq and Syria. It was not possible to independently confirm the claim by the Islamic State.

The two militants — who were killed in a standoff at the museum Wednesday — appear to have been radicalized in their home towns near the Algerian border and apparently traveled to Libya for training, according to local media reports and an interview with a friend of one of the militants’ families. Their brazen assault has highlighted the danger that the violent jihadist movement poses to this nation, which gave birth to the Arab Spring and is struggling to maintain its democracy.

“I want the Tunisian people to understand that we are in a merciless war against terrorism and that these savage minorities do not frighten us,” Tunisian President Beji Caid Essebsi said on Thursday.

Tunisian authorities said nine people had been arrested in connection with the attack, which killed tourists from countries including Italy, Spain, Britain, Belgium, France, Colombia and Japan. In addition, at least one Tunisian security officer died. Officials neither provided details on the identities of the arrested suspects nor described their alleged roles.

Authorities named Yassine Laabidi and Saber — also known as Hatem — Khachnaoui as the militants who stormed the Bardo National Museum. Tunisian Prime Minister Habib Essid had said earlier Thursday that their links to jihadist groups were unclear.

But a friend of Khachnaoui’s family said in an interview that police detained three of the young man’s relatives in a town in central Tunisia.

The friend, Nidal Abdelli, said that Khachnaoui, 19, disappeared about three months ago and that the Tunisian Interior Ministry later informed the family that he had traveled to Derna, in eastern Libya, apparently to receive training. A group loyal to the Islamic State is reported to control parts of Derna, although other jihadist groups are also active there, including the al-Qaeda-inspired Ansar al-Sharia.

Abdelli, 29, said the Khachnaouis are a poor family from the town of Sbetla in Kasserine province, which borders Algeria. Police have arrested Saber Khachnaoui’s father, sister and a brother, Abdelli said. He also stated that when Saber disappeared, his father notified police in Kasserine and the Interior Ministry in Tunis. Nonetheless, the young man managed to reenter the country.

“He’s a kid,” Abdelli said of ­Saber. “He doesn’t know anything. But he’s a victim as much as he is a terrorist. He’s a pawn in a much bigger game.”

“And there was no system in place to prevent him from being radicalized or to get him out once he had been brainwashed,” he said.

Authoritarian leaders for decades imposed secularism on this Mediterranean nation of about 11 million people, most of whom are Muslim. But mass demonstrations in 2011 by citizens angry about corruption and unemployment forced autocratic leader Zine el-Abidine Ben Ali to flee the country. In the more democratic period that followed, extremist groups were able to recruit with greater freedom.

Kasserine was one of the provinces where protests were strong during the revolution, Abdelli said.

“It’s clear that the economic and social issues in places like Kasserine have not been addressed since 2011,” Abdelli said.

In an interview with RTL, a French radio network, Prime Minister Essid said Laabidi had been flagged to intelligence officials, although not for “anything special.” His remarks raised questions about why Tunisian counterterrorism officials had not been more effective.

At the museum on Thursday, police deployed riot vans, barbed wire and dogs as they guarded the entrance. Police officers said that three attackers had opened fire the day before on tourists who had just stepped off tour buses in front of the museum. The gunmen then chased the visitors inside the building, the officers said, speaking on the condition of anonymity because they were not authorized to talk to reporters. They said the gunmen were wearing expensive clothes, including Nike shoes.

“If you saw them, you would never know they were terrorists,” said one officer. Other accounts have described the gunmen as wearing military or police uniforms.

A tour guide, Ala Hamdi, 22, said he had hunkered down with tourists in the museum for more than an hour Wednesday while waiting for the gunfire to subside.

When the shooting broke out, he was with a group of 19 French tourists, he said.

“I put them [the tourists] in the Dougga Room and closed the door,” Hamdi said, referring to a room on the second of the museum’s three floors. He said he told everyone to be quiet as the sound of gunfire ricocheted through the building.

Outside the room he saw an injured tourist whose shirt was stained with blood, Hamdi said.

“He asked me to help him; he said his wife was really bleeding,” he said. He added that “most of the violence was in the Carthage Room,” referring to a larger hall nearby.

“I never thought anything like this would happen here,” Hamdi said.

The attack appeared intended to strike a blow to tourism, a major source of Tunisia’s revenue. It was the worst militant violence here in a decade.

Several hundred people demonstrated Thursday outside the Bardo museum, known for its collection of Roman mosaics, to denounce the terrorist act.

“We must fight this ideology with more culture and more education,” said Ehab Hamdi, 18, who was holding a placard at the demonstration. “I believe the Islamic State could be behind it,” he said of the attack. “But Islam is open — it is not the way they portray it.”

Daniela Deane in Rome, Hend Hassassi in Tunis and William Branigin and Brian Murphy in Washington contributed to this report.

Read more:

The worrisome return of a familiar terror target: tourists

Bardo museum houses amazing Roman treasures

Why Tunisia, Arab Spring’s sole success story, suffers from Islamist violence