But economic progress has lagged well behind. High unemployment has created frustrations among the young and a significant number have looked for answers in radical Islam.
Political opening in Tunisia has given radicals more breathing room, their numbers swollen by the release hardened Islamist militants during the 2011 Tunisian revolution that swept away decades of autocratic rule.
Homegrown terror
One of those who was freed from jail was Seifallah ben Hassine -- also known as Abu Iyyad -- a veteran Tunisian Jihadi who worked with Osama bin Laden in Afghanistan in the 1990s and founded the Tunisian Combatant group. Soon after he was released he founded Ansar al Shariah in Tunisia, a pro-Jihadi movement which has up to 40,000 followers.
The group has a similar outlook to its namesake in Libya which the United States says carried out the attack on the U.S. Consulate in Benghazi on September 11, 2012, and according to Geoff Porter, a terrorism expert at North Africa Risk Consulting, there are real and fluid links between the two groups.
Three days after the Beghazi attack, Ansar al Shariah in Tunisia organized a mob attack outside the U.S. Embassy in Tunisia which put American lives at risk. According to the U.S. government, the group has also been responsible for several other attacks, including attempted suicide bombings at Tunisian tourist destinations.
In October 2013, a Tunisian suicide bomber blew himself up outside a beach hotel in Sousse, killing only himself. Another was arrested in Monastir before he could blow up his device. The two had reportedly tried to travel to Syria but had been persuaded enroute by Jihadis in Libya to bring Jihad home.
In 2013 two secular Tunisian politicians were assassinated by Islamist extremists. The United States said Ansar al Shariah was implicated in the attacks.
In the last two years, Tunisian security forces have increasingly cracked down on Ansar al Shariah, but the movement still has a significant following. Ben Hassine fled to Libya where he is now believed to be based.
Blowback from Syria
The Syrian Jihad has been the single biggest factor in the worsening security situation in Tunisia. Over 3000 Tunisians have flocked to fight Jihad in Syria and Iraq, many of them joining ISIS. And about 500 are believed to have returned stretching the resources of security services.
In December 2014 ISIS released a video calling on Tunisians to pledge allegiance to ISIS and carry out attacks, including assassinations.
The Tunis museum attack took place just days after a Tunisian Jihadi tweeted that a pledge of allegiance by Tunisian Jihadis to ISIS leader Abu Bakr al Baghdadi was coming soon, according to the SITE intelligence group.
The Tunisian Jihadi who posted the message Sunday claimed to belong to "Jund al-Khilafah in Tunisia." In December, a grouping by the same name had pledged allegiance to ISIS. But the earlier pledge appears not to have fully registered with ISIS. An ISIS fighter in Raqqah, recently appeared in a video questioning why Jihadis in Tunisia had not pledged fealty. The Tunisian Jihadi replied "Wait for the glad tidings of what will bring you joy. ... The delay of the public pledge of allegiance was for the sake of preparation."
The statement raises the possibility that the museum attack could be ISIS`s debut on the Tunisian stage, timed to precede a pledge of allegiance from Tunisian Jihadis for maximum impact.
While pro-ISIS twitter accounts lit up in celebration after the museum attack, there had been no credible claims of responsibility as of late Wednesday.
Spillover from Libya
Tunisian security officials are worried about spillover from an increasingly chaotic Libya. ISIS has taken advantage of a simmering civil war in Tunisia`s neighbor to rapidly expand. It is now the dominant force in Derna in eastern Libya and controls parts of the town center of Sirte, the hometown of former Libya strongman Moammar Gadhafi. And it has built an increasingly significant presence in Tripoli itself, carrying out a gun attack on the Corinthia Hotel in January.
A number of Tunisians are also believed to be training with ISIS in a half dozen training camps the group operates in the Green Mountains between Benghazi and Derna in eastern Libya.
The al Qaeda factor
In late 2012 al Qaeda`s North African affiliate AQIM set up a branch in Tunisia called the Uqba ibn Nafi Brigade, a 60-strong Jihadi outfit composed of Tunisians, Algerians, and some Libyans. The group is believed to include fighters driven out of Mali by French forces.
The Uqba ibn Nafi Brigade has been responsible for a string of attacks on Tunisian security services in mountainous Djebel Chaambi region along the Algerian border.
"They have been the most active terrorist organization in Tunisia to date," Porter told CNN. "It is rumored, but not confirmed, that they are getting additional personnel from Algeria because members of AQIM in Algeria have been fleeing intensified Algerian military operations."
Andrew Lebovich, a North Africa security analyst based in New York told CNN that the Uqba ibn Nafi Brigade issued a statement late last year threatening to attack Tunis. "Most of their attacks have been in the Djebel Chaambi region but it`s possible they have extended their operations closer to the capital," he said.
Repercussions
The museum attack is the biggest crisis faced by Tunisia since the revolution. It is likely to significantly impact Tunisia`s tourism industry, worsening the economic outlook and increasing the sense of frustration on which extremists thrive.
There is also concern Tunisian security forces, traumatized by the attack on the capital, could once again embrace repression in their struggle to contain the Jihadi threat.
"The Parliament was debating tougher anti-terrorism laws when the museum attack took place. The worry now is that Tunisia`s security services will crack down hard on Islamists increasing tensions and making the problem far worse," Lebovich told CNN.
More about: