Al-Qaeda in the Islamic Maghreb claimed responsibility for the Grand-Bassam attack in Ivory Coast that left at least 16 people dead on Sunday. This latest attack indicates a strategic shift by the terrorist group: spreading fear and instability further south and destabilising the capitals of the countries involved in fighting against its Sahel bastions. After smearing the streets of Ouagadougou and Bamako with blood over the past six months, the terrorists have added a new country on their list of targets.

In all three cases, such attacks have been intended to derail a steady process of institution building. The objective of these attacks is to fuel hatred and xenophobia while impeding the economic development of societies where fundamentalists hope to recruit more zealots.

The biggest enemy and strongest weapon against fundamentalism is a healthy democratic society promoting a multi-party system and guaranteeing freedom of expression.

Nowhere is this more true than in Africa, a continent whose economic development is often hampered by the weakness of its political institutions.

Targeting hotels

By targeting hotels frequented by Western tourists and entrepreneurs, the terrorists are hoping to attack African economies at their heart, damaging its tourism sector and hampering the attraction of foreign investors.

Sunday's attacks in Grand-Bassam followed this objective as did the recent attack against the Splendid Hotel in Ouagadougou and the raid again the Radisson Blu hotel in the Malian capital Bamako.

ALSO READ: Deadly attack hits Ivory Coast tourist resort

Similarities are striking between the three attacks even beyond the choice of targets. Burkina Faso, Mali and Ivory Coast are three countries which had successfully overcome an era of turmoil to organise peaceful presidential elections.

In Ivory Coast, the last five years have been impressive in terms of institutional reconstruction after the coastal nation was riven by two religious wars...

In Ivory Coast, the past five years have been impressive in terms of institutional reconstruction after the coastal nation was riven by two religious wars from 2002-2007 and 2010-2011 between a government-held Christian south and northern regions under the control of Muslim rebels. As a result, Alassane Ouattara was re-elected by a landslide in a relatively peaceful election last year.

Far from traditional cliches and the image that terrorists want to spread, Western Africa has changed over the past few years. From the peaceful transition in Nigeria between Goodluck Jonathan and Muhammadu Buhari to the stepping down of president Amadou Toumani Toure in conformity with the Malian constitution or the rebirth of democracy in Burkina Faso, the continent has proved its capacity to steadily move towards sustainable democracy despite the terrorist threats.

Ibrahim Boubacar Keita in Mali, Roch Marc Christian Kabore in Burkina Faso and Alassane Ouattara in Ivory Coast were each elected after widely acclaimed ballots in which their opponents peacefully admitted defeat and publicly congratulated the winning candidates.

If Al-Qaeda in the Islamic Maghreb, known as AQIM, and Boko Haram have suffered severe military defeats on the ground recently, the biggest drawback for fundamentalists has been the resilience of Western African societies and their capacity to answer with a commitment to democratic rule.

If the recent terrorist attacks aim to scare away investments essential to African development, they are no more than painful defeats in a war for democracy that is being steadily and slowly won.

Targeting secularism

Beyond Ivory Coast, the indirect target of Sunday's attack are both France and a commitment to secularism in western Africa. Indeed, in 2014, Paris announced that its former colony would be its base for fighting Islamist terrorism in the Sahel region.

A 3,000-strong task force of French solders has been based there ever since. Similarly in July 2015, foreign imams were banned from preaching in mosques in the north of Ivory Coast and the government suspended the construction of new radical mosques around the northern city of Ouangolodougou. The renewed French involvement in the subcontinent is hampering the progression of fundamentalists' ideology and interests.

Each of the Western African countries recently attacked by AQIM benefited from the benevolent support of the former coloniser, France, and Francois Hollande's administration, which broke away from his predecessor's resolute decision to support authoritarian leaders at the expense of democratic demands.

If French interference in African domestic affairs is far from over, the approach is vastly different. Sarkozy's speech belittling the "African man who had failed to enter history" has thankfully been replaced by a more humble support to endogenous institution building supported by the current French president.

The growing political democratic stability of Western African countries which face terrorist threats on a daily basis is also a lesson for populations in industrialised countries in Europe and the United States. While the latter have decided to cower into debates on national identity and to turn more and more towards populistic leaders - from Donald Trump to Viktor Orban or Marine Le Pen - the former have shown a political maturity that breaks with the obsolete cliche on Western Africa.

The outcome of the war on terrorism in the continent will depend on the capacity of African societies to continue supporting their newly democratically elected regimes. The same holds true for Europe and the United States following the attacks in Paris and San Bernardino.

If local populations turn their back on mainstream liberal parties and answer the xenophobic calls of extreme movements and leaders, then the terrorists will have achieved their objectives. This would boost their capacity to recruit and only increase the rate of attacks.

Whether in Ivory Coast, Mali or in Burkina Faso, whether in recently stricken Indonesia, Turkey or Tunisia, the reinforcement of liberal democracy is the only cure to the terrorist cancer.

Remi Piet is assistant professor of public policy, diplomacy and international political economy at Qatar University.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial policy.