In the first two weeks of 2020, the Somali armed group al-Shabab carried out five attacks in Kenya, killing more than a dozen people.

On January 2, the group attacked a bus in Lamu county near the Somali border, killing three people. Three days later, again in Lamu county, an al-Shabab attack on a military base killed three Americans.

On January 7, the group attacked a primary school in Garissa county near the Somali border, killing four students and a teacher. Three days later, it raided a police station in Olla area, Mandera county.

On January 13, al-Shabab gunmen attacked another school in Garissa county and killed three more teachers.

While the frequency and effectiveness of the attacks were undoubtedly alarming, they did not come as a surprise to anyone familiar with Nairobi's decade-long struggle with the armed group.

Kenya has been a regular target for al-Shabab since it sent troops into Somalia to fight it in 2011. The incursion, code-named Operation Linda Nchi (defend the nation), succeeded in recapturing many towns and villages from the group. But this success came at the cost of endangering the safety of its citizens.

Shortly after the incursion, al-Shabab started terrorising Kenyans inside Kenya. In September 2013, al-Shabab gunmen killed 67 people in Nairobi's Westgate Shopping Mall. Less than two years later, they massacred 147 more people at Garissa University College.

Despite scoring some initial gains, Operation Linda Nchi did not succeed in ending al-Shabab's reign of terror in Somalia, either. Thanks to the efforts of the Kenyan military, as well as the African Union (AU) peacekeepers stationed in Somalia under AMISOM, the group was forced out of Mogadishu in 2011 and has since lost most of its other strongholds in the country.

Nevertheless, its fighters continue to attack sites in Somalia regularly and with impunity. Al-Shabab was responsible for a horrific truck bombing in Mogadishu in October 2017 that killed more than 500 people - the deadliest single attack in the country's history. Just a few months ago, another attack by the group near a checkpoint in Mogadishu killed at least 78 people.

Al-Shabab's continued ability to carry out elaborate terror attacks both in Kenya and Somalia proves that counterterrorism policies of regional powers which rely solely on military power are not working. To bring an end to the group's deadly attacks, in Kenya, in Somalia, and elsewhere in the region, regional authorities urgently need to change strategy.

Recent developments in the Afghan war, including the talks between the US and the Taliban and the negotiated a "reduction in violence" agreement, can provide a blueprint for the resolution of Somalia's conflict.

After spending over a trillion dollars and sacrificing hundreds of lives in its fight against the Taliban in Afghanistan, the US government, under President Donald Trump, has decided to change tack and try to resolve the conflict by negotiating with the Taliban leadership.

While a peace deal has not been signed yet, there is increasing hope that a few diplomats will soon succeed in doing what thousands of soldiers failed to do for decades and bring an end to this devastating conflict.

While the conflicts in Somalia and Afghanistan undoubtedly have significant differences, they also have some important similarities. First, the conflicts in both countries have a high human toll both inside and outside of their borders. Second, the internationally recognised governments in both countries are incapable of resolving the crises they are facing on their own. Third, the primary foreign powers involved in these conflicts - the US in Afghanistan and Kenya in Somalia - are under increasing domestic pressure to end their military involvement in these countries.

Both Kenya and the African Union did everything in their power to defeat al-Shabab militarily. They failed. Insisting on a failed strategy will achieve nothing but more conflict, death and devastation. Now, it is their duty to negotiate with the enemy they failed to defeat. Only through negotiations can they achieve sustainable peace, which would allow Somalia to gain back its sovereignty and Kenyan citizens to feel safe in their schools, shopping centres and homes.

Some may say al-Shabab, a terrorist organisation, does not deserve a place at the negotiating table, but this is not the case. We make peace not with our friends but our enemies - and this includes terror groups.

A quick look at African struggles for independence could show us how it is sometimes necessary to negotiate even with the cruelest and most undeserving of enemies. After all, only a few African countries succeeded in pushing out their colonisers soley through an armed struggle. The vast majority achieved freedom by negotiating with their oppressors.

Thus, it is time that the AU and the Somali government reach out to al-Shabab and sit down at the negotiating table with them. Tribal elders can be engaged to bridge the trust deficit between the three sides.

Just like the US, the AU and the Somali government could use the withdrawal of foreign troops from Somalia as levarage to push al-Shabab to commit to a ceasefire. A political solution could be put forward in which al-Shabab leaders are offered to join the government and plans are made to integrate their fighters into the Somali armed forces.

"We don't negotiate with terrorists" should not be a hard and fast rule, especially as innocent people continue to die at the hands of these terrorists. If African leaders do not soon acknowledge the failure of the military approach and invite al-Shabab to the negotiating table, Kenya, Somalia and other countries in the region will welcome many more new years with bombs, and lose thousands more civilians to this senseless conflict.

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