This week terror again came to Tunisia. An attack on a bus carrying presidential guards in the capital Tunis took the lives of 12, with dozens others wounded.

In a statement posted on social media, ISIL claimed responsibility, saying a Tunisian militant named Abu Abdallah al-Tunisi had boarded the bus wearing an explosives belt as it picked up guards on their way to work on Tuesday.

The blast occurred only a few hundred metres from the interior ministry.

The bombing has further jangled nerves in Tunisia, which has been buffeted by two major attacks this year - both also claimed by ISIL. In June, a gunman massacred 38 foreign tourists, including a number of Irish citizens, during a rampage at the popular beach resort of Sousse.

That attack was the deadliest targeting tourists in the region since the 1997 massacre of more than 60 holidaymakers in Luxor, Egypt.

A few months before Sousse was targeted, two ISIL militants stormed the Bardo Museum in Tunis, killing 21 tourists and a police officer.

In a subsequent audio statement, ISIL said it had targeted "crusaders and apostates" in the Bardo strike and warned that it was "just the start".

In recent weeks, Tunisians were chilled by the beheading of a young shepherd, who was accused by jihadists of having informed the military about their activities.

The attack this week on the presidential guard was not the first time Tunisia's security forces have been targeted. Last year a bus carrying troops was attacked by gunmen in northwest Tunisia. Five soldiers were killed.

That July, 15 soldiers were killed by militants near the Algerian border in the worst such attack in the Tunisian army's history.

The country which birthed the so-called Arab Spring in 2011, toppling the decades old autocracy of Zine El-abidine Ben Ali through popular protests, is grappling with the increasing threat posed by domestic terrorism as it navigates its delicate transition from dictatorship to democracy.

In the wake of this week's attack, there was a mood of defiance in the capital, but also a sense of unease that this would not be the last. "Tunisia will not bend," said Le Temps, a daily newspaper. "United against barbarism," declared Le Quotidien.

President Beji Caid Essebsi ordered a curfew for Tunis and a nationwide state of emergency less than two months after the previous one, imposed after the Sousse attacks, had been lifted. The border between Tunisia and Libya has been closed for 15 days.

Many Tunisians fear the battle against domestic terrorism will be a protracted one. Tunisia is believed to provide the largest number of jihadists overseas - the authorities here say at least 3,000 of its nationals are fighting in Syria and Iraq.

A significant number of Tunisians have joined extremists, including ISIL, in neighbouring Libya - where a political power struggle has created a vacuum in which such groups can flourish. The authorities are concerned about what happens when these Tunisian-born militants return home, seeing in the attacks this year a bloody portent of what may be to come in the not-too-distant future.

Such attacks threaten to devastate what is left of the country's already ailing tourism sector, the backbone of its moribund economy.

Hotel owners lamented a drop in business during the remainder of the peak summer season as nervous tourists opted to stay away after the Sousse attack.

"There is very little we can do to change people's perceptions," said one hotelier in Tunis this week. "Too much has happened already this year."

A further backsliding for Tunisia's already shaky economy would be disastrous. The protests that eventually led to the overthrow of Ben Ali in 2011 were largely driven by anger over economic stagnation in the country, particularly among a youthful population grown frustrated due to chronic unemployment and bleak prospects.

Many believe these restless youth, whose high expectations after Ben Ali's ousting have not been met, are easy prey for extremist groups like ISIL.

Tunisia received a boost in October when a quartet of civil society organisations was awarded the Nobel Peace Prize in recognition of their efforts to foster an inclusive transitional process.

The Nobel committee said it hoped the prize would help safeguard democracy in Tunisia and be an inspiration to all those seeking to promote peace and democracy in the region.

Despite all the challenges - from political to security and economic - the country's fragile transition remains something of a beacon of hope for others in the Middle East and North Africa.

"At times we feel almost a burden of expectation because so many are depending on us to show what is possible," said one activist this week.

"The challenges - like what happened this week - can be overwhelming, but we must succeed."