Security consumes almost half of Somaliland's state budget | Mohamed Abdiwahab/AFP via Getty Images The Coming Wars How to fight terror, the Somaliland way In the breakaway republic, a strict clan system keeps al-Shabab in check.

HARGEISA, Somaliland — How do you root out a ruthless terror group? How do you anticipate its every move, counter its indoctrination campaigns, occupy its territory and deprive it of the air it breathes?

I was contemplating these questions while standing in the inner courtyard of the Presidential Palace in Hargeisa, the capital of Somaliland, when the man who knew the answers walked up to me and introduced himself.

“I am Ali Waran Ade, the lionkeeper of Somaliland,” he said. Waran Ade received that name because of the lions he owns. He keeps them in his farm by the dry river bed in the east of the city. A few years ago, one escaped and killed a woman at the livestock market in the capital.

Gray-haired and gray-bearded, Waran Ade is a security adviser to Muse Bihi Abdi — the recently elected president of the self-declared independent republic that broke away from Somalia in the early 1990s. But Waran Ade has also served as interior minister under three of Abdi’s predecessors.

No one knows better than him the underworld in which the terror group al-Shabab likes to operate. The group has wreaked terrible violence in neighboring Somalia, where it basks in an aura of invincibility that has eluded al-Qaeda and ISIS. The United States-led international contingent in Somalia seems impotent against them. After years of conflict, al-Shabab continues to operate with impunity in Mogadishu, where the government and foreign aid workers keep to a small cordoned-off area.

And yet, in Somaliland, al-Shabab has no presence — even though part of its leadership originally came from Hargeisa. So how has this small, impoverished, internationally unrecognized state on the Gulf of Aden succeeded where everyone else has failed? What does it know that everyone else is unable to understand?

The old lionkeeper knows the answer — but it’s not what you’d think. Yes, his efforts and those of the interior ministry are important. Security consumes almost half the state budget, the borders with Somalia are carefully guarded, and more than a few dangerous characters have disappeared into state prisons.

But credit for Somaliland’s success doesn’t belong to the security services, Waran Ade told me. It belongs to the people. No security service can know everything its enemies are up to, but the people are everywhere. They know everything, hear everything, spy on everything. Only the people can become one with the people.

I am told numerous stories to illustrate the point. Once, two old ladies near the Ethiopian border spotted a group of young men carrying weapons; they immediately reported them to the police. Even mothers are not above reporting their sons if they see a call from Mogadishu registered on their cell phones.

Thirty years ago, in a drawn out civil war with Somalia, Hargeisa was razed to the ground. Everyone in the region is willing to pay any price to preserve what has since been built: an open democracy and a thriving new landscape of small businesses filling every street in the capital.

Life feels so safe now that local merchants in the bazaar leave their piles of shilling — inflation is a problem — unattended when they go to pray in the nearby grand mosque.

Democracy in Somaliland is a living organism, not a system built after foreign invasions, erected according to the prescriptions of think tanks and political consultants. It is old — much older than its European cousins, lost in a distant past of nomadic freedom and independence. And it is built on the foundations of a clan system which, far from subjugating the individual to archaic traditions, actually gives him or her the power to stand up to the state and preserve its limits.

Somaliland is the only place in the Horn of Africa where the clans have survived intact. The British colonial presence was very light, and for the past few decades the country has lived in isolation. In Somalia, the clans were uprooted by the Italian occupiers and now resemble political cliques.

A young man in Somalia is easy prey for al-Shabab. His social status is given an enormous boost if he joins the group. He will be given a cell phone, a monthly salary and a pick of beautiful women, who are coerced into marriage. If he says no, he will have to pay a tax or offer his services for free. And if he says no again, he is killed.

People in Somaliland feel sorry for Europeans, who are alone in the world and have to drag themselves through life without present or past.

In Somaliland, a young man who is found out to have any connection to al-Shabab will have to run away and remain a fugitive all his life. His clan will make sure of that, because the association will be a stain on the honor of the whole clan. To be a clan member is to be able to recite one’s ancestors 20 or 30 generations back.

The system links everyone to the past. As someone told me, people in Somaliland feel sorry for Europeans, who are alone in the world and have to drag themselves through life without present or past.

So picture this: two formidable political creatures. One is a terrorist group more than 10 years old, renowned for cruelty, indiscriminate executions and the power to hold an entire country in its grip. The other is a small state, unrecognized by the international community and so impoverished that its capital is still unable to afford traffic lights.

Remarkably, the latter has won the war. Or put it more prudently: It is winning the war.

Before I walked in to meet the president, Waran Ade told me that his successor in the ministry had gone to the north to try to put an end to a bloody clan dispute. Regrettably, these things sometimes get out of control. One death is avenged with another and the cycle can go on forever.

So the government and the House of Elders — a house of parliament representing the clans — have sent delegations to mediate the conflict. A written document will be signed and peace may perhaps return.

And that, Waran Ade told me, is the last part of the secret: Clans are not social clubs, they are not tame and gentle. They can be violent and bloody and fierce. But this is a land of blood and violence. You don’t defeat the devil if you are not fierce yourself, if your blood is not of the same land.

Bruno Maçães, a former Europe minister for Portugal, is a senior adviser at Flint Global in London and a nonresident senior fellow at the Hudson Institute in Washington. His book “The Dawn of Eurasia” was published by Penguin in January.

Authors: