Tunisia, the country that first propelled the popular uprisings in the Arab world five years ago when a frustrated street vendor set himself on fire, has become the latest front line in the war against Islamic State militants.

Last week dozens of IS fighters launched a dawn attack on army and police posts in the coastal Tunisian town of Ben Gardane near the Libyan border. A total of 48 fighters from both sides were killed – along with seven civilians who included a 12-year-old girl – in a battle that lasted for hours.

Most of the attackers were Tunisians, authorities said, and already were established as a well-trained IS unit inside the town.

Story continues below advertisement

Last June, a Tunisian linked to Islamic State killed 38 people, mostly British tourists, at a beach resort of Sousse further north; an attack in March, 2015, left 22 dead at the Bardo museum in Tunis. The man responsible for the Sousse attack is believed to have been killed in the U.S. bombing last month of an IS training facility across the border in Libya.

"Tunisia should expect further attacks," said a report by the International Crisis Group last week, citing the anarchic conditions in Libya that have left a political vacuum into which Islamic State has moved.

This has become a serious challenge for Tunisia, the Arab country that has advanced furthest toward a peaceful democracy after its revolution in 2011.

Tunisian President Beji Caid Essebsi of Tunisia said in a televised address last week that Islamic State militants are trying to create a new IS territory on Tunisian soil, similar to the 250-kilometre coastal stretch it controls in Libya. Some 3,000 Tunisians are believed to have left the country to fight for Islamic State in Syria, Iraq and Libya, with a growing number now returning to fight in Tunisia.

Unless Tunisia can stem the tide of these jihadists, said Rafik Abdessalem, the former foreign minister in the country's first democratically elected government, "all our advances will be for naught."

To do that, he says, "we need a political solution to the crisis in Libya" from where most of the IS fighters are returning.

Since the demise of Libya's long-time dictator Moammar Gadhafi in 2011, the country has been torn apart in a gigantic tug of war between religious and secular factions, compounded by tribal divisions. At the moment, the forces most resembling a government, and recognized as such by much of the international community, are set up in Tobruk in the east of the country, while a relatively moderate religious coalition, led by the Muslim Brotherhood and supported by Qatar and Turkey, holds forth in Tripoli in the west. In between are smaller territories, one ruled by Islamic State, others by various religious extremists.

Story continues below advertisement

A United Nations-backed plan for a national unity government has been rejected by the Tobruk authorities.

In the absence of any national law and order, Islamic State has set up training camps that are turning out growing numbers of fighters. As well, the Gadhafi arsenals have been opened up and lethal weapons spread all around.

"Until that country comes together with a government for all the regions, all the tribes – one that is fully supported [and armed] by the international community – it will continue to be a place for Islamic State and other groups to fester and grow, and for some of our people to learn how to be terrorists," argues Dr. Abdessalem, a member of the moderate Islamic party Ennahda, who was in Canada last week to encourage support for Tunisia.

"The international community [including Canada] must pressure Tobruk to join with Tripoli in this unity government," he said.

As well, Tunisia needs an infusion of capital to stimulate and develop its moribund economy, said Dr. Abdessalem – a total of $20-billion over the next two years.

"We need to be able to defend our own borders and to provide jobs in all parts of the country so these young men won't turn to Islamic State," he said.

Story continues below advertisement

Before the fall of Mr. Gadhafi, he noted, there were 400,000 Tunisians working in Libya, sending back money to their families. Today, the situation is reversed with some 300,000 Libyans living in Tunisia. "Many of them came with some money but now it has run out," Dr. Abdessalem said.

As a student activist for the Ennahda Party in the late 1980s, Dr. Abdessalem was forced to flee the country when Zine El Abidine Ben Ali took power and cracked down on Islamic groups.

To this day, many people in Tunisia complain that his party is too religious. "But all the time others say: 'you're not religious enough,' " he notes.

"Ennahda is the antidote to terrorism," says Dr. Abdessalem, who returned to Tunisia in 2011. "We are a Muslim party, but we don't want to force anyone to do anything; we believe in democracy."

Indeed, Ennahda, the principal party in Tunisia's first democratic government, chose to step down voluntarily from power in 2013 so that new elections could take place, rather than hold onto office at a time when sectarian tensions threatened to erupt.

The party's move followed a pair of assassinations of secular leaders that were carried out most likely by the militant Salafi group Ansar al-Sharia but blamed on Islamists in general. The subsequent election resulted in a diverse coalition of secular and moderate Muslim parties, with Ennahda, still holding the largest number of seats in the Parliament, declining the prime minister's office, and taking only two cabinet portfolios.

Story continues below advertisement

Commenting on this unusual move, Dr. Abdessalem said he is proud that Ennahda "put country above the party."

He acknowledged that his party must continue to prove it is not an extreme Islamist movement but a moderate force.

"There is a clear line between Ennahda and Islamic State," he insists. "[Yes] we are Sunni [and Islamic State is Sunni] but with a very different interpretation of Islam."

It is this willingness to compromise, even in the face of sectarian hatred, that has set Tunisia apart from other Arab states that also overthrew dictators and, until now, has made Tunisia a model for other countries.

Dr. Abdessalem says three things make Tunisia different: "the homogeneity of our society," is the first, he believes. "We are not tribal" the way so many other countries are.

Second, is the country's army: "We don't have a history of military intervention," he notes. Indeed, the army refused to support then-president Ben Ali when he was faced with the popular uprising in 2011.

Story continues below advertisement

And third is "the rationality of the main political players." He cites his own party Ennahda as the prime example. "We made concessions in order to preserve the democratic system."

"We did not want to go the way other countries have gone."

However, he points out, while Tunisia has produced a progressive new constitution and a viable coalition government, "our economy is not keeping up with political progress … and that's a real problem."

"The international community spends billions on waging wars, and on sheltering refugees from conflict," Dr. Abdessalem notes.

"We say it would be better to spend the money on supporting democratic rule [and free enterprise] and avoid the wars in the first place."