Tunisia attack
A tourist injured after an attack by gunmen on Tunisia's national museum is wheeled on a stretcher in Tunis March 18, 2015. REUTERS/Stringer

Two days before Wednesday’s attack on a museum connected to the Parliament building in Tunisia, an ominous message was circulated on social media accounts affiliated with the Islamic State group: An attack in Tunisia had been planned and militants were ready to execute.

Between two and five gunmen opened fire at Tunisia’s Bardo Museum, killing at least 20 people. The gunmen, and their allegiance, have not been identified, but since Monday social media accounts affiliated with the militant group -- which is also known as ISIS or ISIL -- have been spreading a message claiming an attack in Tunisia was imminent. If true, this is one of ISIS’ biggest attacks, and the first time the militant group pre-emptively announced an attack outside its so-called caliphate in Iraq and Syria. The attack also stands out for its location, a nation with a relatively stable, secular government that, although the source of many ISIS fighters, had never been attacked by the group.

“There are two versions of this message. There is one version of this message for the Muslims, that says ‘a message that will rejoice you,'” said Pieter Van Ostaeyen, an independent analyst who focuses on foreign fighters in Syria. “There is another version that would be sent out to the enemies that said ‘a message that will harm you.’”

The message did not give any further details about the attack.

Earlier this week, a member of Tunisian jihadist group Ansar al-Sharia, affiliated with ISIS, warned Tunisians that attacks were going to take place in the North African country within the coming days. Ansar leader Wannes Fakih reportedly spoke in an audio recording released on YouTube and disseminated over social media Tuesday. One of the gunman had an Ansar flag with him, according to an officer in Tunisia’s National Guard who spoke on the condition of anonymity, because officers are not allowed to speak to reporters.

Van Ostaeyen said he received a direct message on Twitter, aimed at ISIS supporters, that said, “Urgent news the state of the caliphate will soon send you a message about the state of Tunisia.” He expected there to be an allegiance announcement, he said. In reality, the message referred to Wednesday’s attack.

“They were military uniforms, they had Kalashnikovs, they had hand grenades,” Van Ostaeyen said. “In my idea, this must have been planned for several days and maybe even weeks in advance.”

The warning messages coincided with the death announcement of Tunisian-born Ahmed al-Rouissi, who went by the nom de guerre Abu Zakariya al-Tunisi or Abu Uwais al-Tunisi. Al-Tunisi was an ISIS leader in Libya and was wanted in Tunisia for assassinating two politicians in 2013. He was reportedly killed in clashes with Libyan militias earlier this week.

The death of al-Tunisi may have been a reason to pull the trigger for the attack, but ISIS has had a gun pointed toward Tunisia for a while. In December, three allegedly Tunisian fighters appeared in a propaganda video titled “A message to Tunisia,” and warned that ISIS would "spread, God willing ... despite the enemies, to the lands of Tunisia."

A statement from the same media house released in early March claimed that the Tunisian government had declared a war on the Islamic State group. The statement also issued a list of “commitments” that its supporters had to make to hide their affiliation for the coming months to ensure that “sleeper cells and reserve soldiers” were not arrested.

Among the ISIS recruiters in Tunisia is Tunisian citizen Tariq Bin Al Tahar Bin Al Falih Al 'Awni Al Harzi, who was added to the U.S. Designated Terrorist List in 2014, was known as the “emir of suicide bombers,” and was the man in charge of ISIS operations outside the self-declared caliphate in Iraq and Syria, according to the U.S. Treasury. Al-Harzi’s current whereabouts are not known.

In December, ISIS spokesman Sheikh Mohammed Adnani al-Shami called for the groups’ supporters to carry out "lone wolf" attacks, but he warned that the attacker should keep his plan a secret and not seek outside help. So far, the "lone wolf" attacks carried out by ISIS supporters have had no direct link to ISIS leadership. The same cannot be immediately said about the attacks in Tunisia, a nation that has had at least 3,000 people leaving to fight with ISIS, many of whom have returned home.