A policeman carry's a baby to safety after masked gunmen stormed an upmarket mall and sprayed gunfire on shoppers and staff, killing at least six on September 21, 2013 in Nairobi. The Gunmen have taken at least seven hostages, police and security guards told an AFP reporter at the scene.

NEW YORK — During the deadly four-day siege of Kenya's Westgate Mall, which finally ended Tuesday, a message attributed to the attackers called the bloody operation "retributive justice" for the Kenyan military's "crimes" committed in Somalia.

Kenya’s army invaded Somalia just under two years ago, in late October 2011, in a move that was not without provocation.

Kidnappings of Western tourists by Al Shabaab, the Somali Islamic extremist group, had severely damaged the tourist industry.

A spate of smaller grenade attacks in Kenya’s capital Nairobi and the port city of Mombasa stirred memories of the dual 1998 blast that killed hundreds of Kenyans, Americans and others at the US Embassy in Nairobi and in neighboring Tanzania — the handiwork of Al Shabaab’s mentors, Al Qaeda.

As Kenya’s late internal security minister, George Saitoti, said at the time: “Kenya has been and remains an island of peace, and we shall not allow criminals from Somalia, which has been fighting for over two decades, to destabilize our peace.”

From a military standpoint, the invasion went well. It drove Al Shabaab out of strongholds, secured Kenya’s southern border and even won approval from the United Nations Security Council, the African Union (AU) and most of Kenya’s neighbors.

But the assault on Nairobi's upscale mall last weekend is an appalling price to pay. The mall attackers hit Kenya where it hurts: in the striving, newly affluent ranks of Nairobi’s middle class.

They killed 61 civilians and six security force members, according to Kenyan President Uhuru Kenyatta, who added that the death toll could rise. He called for three days of mourning.

The attack, in many ways, is a reminder that even competent interventions carry risk, particularly when they appear — at least to some eyes — to be doing the West’s bidding.

Stronger, richer nations have felt the sting of allying with what used to be called America’s “war on terror.” Spain and Britain both have been targeted with major Al Qaeda attacks, and both notably absent from some subsequent US-led military adventures — Syria included.

Kenya had for decades refrained from participation in such coalitions, even as it remained a stalwart Western ally in sub-Saharan Africa.

Historically, it has eschewed the more radical African viewpoints, first under long-serving pro-Western dictator Daniel arap Moi, and then, after successive democratic elections, as a reliable ally of Europe and the United States and a leading voice for market economics on its continent.

By 2011, however, the stakes had risen for Kenya as it balanced the unpredictable risks of a failed state on its borders against the increasingly strident demands of its growing middle class and huge underclass for a share of economic growth.

Inside Somalia, by 2011 Al Shabaab was on the defensive after successive battles with AU peacekeepers, Ethiopian forces and rival Somali militias. The nascent central government of Somalia appeared at last to be gaining some control over the country — albeit mostly in the capital, Mogadishu.

What’s more, the Kenyan invasion was to be supported with logistics, intelligence and the occasional drone strike by the US and France.

But sweeping militants out of dusty border towns is not the same as securing the country, in spite of the invasion’s PR label: “Operation Linda Nchi” — Swahili for “protect the country.”

Nairobi had long since become a vital destination for the talented, the ambitious and the nefarious from the country’s shattered neighbor, Somalia. Refugees huddled on the border and — as the 1998 bombings demonstrated — militant Islam had at least a foothold in the teeming shantytowns.

All this makes a “rich” Nairobi neighborhood a tempting target for God’s warriors. What an attack lacks in humanity or cunning could be claimed back in symbolism and global media attention.

As a would-be nexus of East Africa’s banking, energy and investment boom, slum-ringed Nairobi has developed a core of affluence familiar to anyone who has visited other striving emerging market megacities, such as Sao Paulo, Lagos, Bangkok or Mumbai.

Bodyguards, armored limousines, Western business people and tourists, “big men” with entourage in train — these are scenes common in all such places.

Yet with oil and gas discoveries raising the prospect of an energy boom, Kenya has struggled to overcome its own difficult legacy of authoritarian rule and divisive, often violent tribal rivalries to project an image of modernity.

The 2007 electoral violence, which pitted tribe against tribe and led to an estimated 800-1,500 deaths, was a reminder of the fragility of the nation that fashions itself the leader of East Africa.

This year’s vote went more smoothly, with an important caveat: It elected a president and deputy now under indictment by the International Criminal Court for war crimes connected to the 2007 bloodshed. The charges against President Kenyatta led US President Barack Obama to skip a long-planned visit to Kenya during a tour of Africa earlier this year.

But Kenyans are optimists by nature. They point to investors who flock to their energy sector and tourists who come to see the country’s natural wonders. There’s also the homegrown technology success, such as M-Pesa, a system that allows nearly full banking services through a person’s cellphone. That’s revolutionizing the middle classes in Africa by allowing them access to credit.

And yes, even after the snub, they point to the heritage of the American president whose administration cheered as Kenyan troops entered Somalia.

Related Stories