An attack by Islamic State militants on Tunisia's presidential guard has left this North African country, its economy and its democracy even more vulnerable just days before four Tunisians head to collect the Nobel Peace Prize.

Five years ago, a desperate Tunisian street vendor set himself on fire, unleashing a pro-democracy movement that swept the Arab world. This week, a Tunisian street vendor blew himself up on a presidential bus, killing 12 others in the name of the Islamic State and further darkening hopes for this country's economy and newfound freedoms.

Alone among the nations that underwent the turmoil of the Arab Spring, Tunisia has emerged as a democracy, but just this last year has seen three devastating terrorist attacks claimed by the Islamic state that killed more than 70 people, mainly tourists and security forces.

What Tunisia needs now, analysts and the government say, is better intelligence and jobs for youth who see holy war as their only future without resorting to the brutal tactics that first sparked the revolution.

After each attack, the government has promised better security — including passing a counter-terrorism law over the summer criticized by human rights activists as draconian — yet the attacks have continued.

Their goal is to "seed chaos and destabilize the country, and in doing so, make a fledgling democracy fail," Prime Minister Habib Essid said after the attack Tuesday, when a street vendor-turned-suicide bomber hopped on a bus carrying members of the elite presidential guard, killing 12 of them.

In March, two gunmen trained in a camp in neighboring lawless Libya unleashed carnage in the country's leading museum, the Bardo, killing 22, mostly foreign tourists.

Three months later, the Mediterranean beach resort of Sousse was the stage of a bloody operation by a student, also trained in Libya, who killed 38 tourists, mostly British.

Tunisia has already sought Western help for better police and border technology, built a sand wall on the Libyan frontier and shut down social media accounts of people suspected of terrorism links.

But the problem is deep and broad.

More than 3,000 Tunisians are believed to be fighting along with other Islamic extremists in Syria, Iraq and Libya, and several hundred are believed to have returned to Tunisia and authorities have had trouble tracking them.

"While Tunisia has stepped up its policing, which is relatively easy to do, its intelligence capabilities, which are significantly harder to develop, are lagging," Geoff Porter of North Africa Risk Consulting said in a research note.

The overthrown regime of Zine El Abidine Ben Ali was known for its ruthlessly efficient network of informers, but they targeted mainly political dissidents and not the hardened jihadis in the poor neighborhoods.

Police, who are regarded with a great deal of suspicion by many sectors of society because of their brutal reputation, have struggled to build up networks of informers among the urban poor that feed the ranks of the jihadis.

The government announced a new string of measures after the latest attack to combat the extremists, putting the country back under a state of emergency with an overnight curfew around the capital.

"It's total war against terrorism," the president's office said in a statement. The border with Libya has been closed and security tightened at sea ports and airports.

The government is now revising next year's budget — already tight because of economic troubles — to spend more on security and defense. It plans to create 6,000 more jobs linked to the army and police.

They're also trying to speed up court proceedings — some 1,200 terrorism-related cases have been dragging through the courts for years.

Issandr El Amrani, the North Africa director for the International Crisis Group, said efforts at beefing up intelligence gathering are just starting out and without a coherent strategy for reform it will be easy for police to fall into the kind of bad old habits that just feed the problem.

"The government as a whole — not just security forces — need to address socio-economic woes," he said. "Otherwise the security forces end up having to bear the brunt alone, and Tunisians from marginalized areas — especially the urban poor and those in interior provinces — end up increasingly hostile to a state they only interact with when police are sent in."

Samir Taieb, head of the opposition Al Massar party is all for a muscular government response, including calling up reservists, but he too cautioned not to forget the social and economic dimensions of the crisis, including a 25 percent unemployment rate among young people.

"We should also pursue the path of dialogue and consensus that won us the 2015 Nobel Peace Prize," he said. Four Tunisian groups in the National Dialogue Quartet won this year's prize for their efforts in 2013 to resolve a constitutional crisis and rescue the country's efforts to build a democracy.

Residents of the capital don't appear to be ceding to fear despite this week's attack and crowds have been lining up to see movies as part of the Carthage Cinema Festival currently under way.

The night of Tuesday's attack, organizers decided to go ahead with the show.

"If the terrorists think they'll scare us, they've got the wrong address," said 30-year-old public servant and festival-goer Ahmed Sassi. "We are attached to life, we love culture and we will continue to go out."

___

Angela Charlton in Paris and Paul Schemm in Addis Ababa, Ethiopia, contributed to this report.