Kenya has long been an African success story, a place that's been relatively stable, peaceful and prosperous despite being in a neighborhood rocked by major disasters for decades.
There's been endless civil war in Somalia, genocide in Rwanda and famine in Ethiopia. Yet these calamities have, by and large, not spilled over to Kenya, which has been the crossroads of East Africa, serving as a business, transportation and tourist hub.
This also explains why an upscale mall in Kenya's capital, Nairobi, was an ideal target for al-Shabab, the Somali militia with ties to al-Qaida.
"Kenya is full of Western interests and if al-Qaida wants to target America, which is obviously its reason for being, Kenya is the place to be," Bronwyn Burton of the Atlantic Council told NPR's Morning Edition.
"They would much rather be operating in Nairobi, where they can hurt more people and they can make more progress in their jihad than they could ever hope to accomplish in Mogadishu," Burton says.
Kenya has always been one of the most outward-looking African countries with its wide-ranging links to the U.S., Europe, the Middle East and Asia.
International companies and aid groups operating in Africa are likely to have a base in Nairobi. Western countries maintain large embassies in Nairobi. And the country swarms with well-heeled Western tourists headed on safaris to Kenya's spectacular game parks.
For these reasons, Kenya depends heavily on its reputation as an island of stability. And that reputation can be easily damaged by terrorist attacks, which can instantly drive away potential visitors.
Counterterrorism experts have been warning about Kenya's vulnerabilities for years.
The country shares a long, unguarded border with Somalia, which smugglers use to ferry weapons and other contraband. Kenya has absorbed many Somalis, with a large concentration in the "Little Mogadishu" neighborhood of Nairobi. And some parts of this Somali diaspora support al-Shabab.
Kenya has rarely intervened militarily with its troubled neighbors. But two years ago, Kenya sent troops into Somalia in an attempt to tamp down the chaos there.
The Kenyan forces went after al-Shabab and took territory held by the Islamist militia, including the southern Somali port city of Kismayo. In response, al-Shabab warned it would target Kenya. The group made good on that threat with the strike on the Westgate Mall, a place frequented by well-off Kenyans and many foreigners living in Kenya.
"We went as a nation into Somalia to help stabilize the country and most importantly to fight terror that had been unleashed on Kenya and the world," said Kenyan President Uhuru Kenyatta.
For Kenyatta, the Nairobi mall attack was personal — his nephew and the nephew's fiancee were killed.
The U.S. has been working with Kenya to develop its anti-terrorism efforts. But in general, Kenya's security forces, and the police in particular, are seen as poorly trained and widely corrupt.
Kenya's Mounting Problems
While the terrorist attack came from abroad, it was the latest sign of mounting turmoil in Kenya.
The country held tense but peaceful elections in March, won by Kenyatta. However, he faces trial in November at the International Criminal Court for allegedly inciting violence that claimed more than 1,000 lives after the country's 2007 election. Vice President William Ruto was already on trial at The Hague, but it was adjourned Monday owing to the ongoing crisis at the Nairobi mall.
In another recent blow, a large part of Nairobi's airport — the most important air transportation hub in East Africa — was destroyed in a major fire in August that's still under investigation.
And in a slap to Kenya's pride, President Obama, whose father was Kenyan, has yet to visit the country during his presidency. Obama stopped in neighboring Tanzania during an African tour in July. But the White House decided against a stop in Kenya, where the president presumably would have been been photographed shaking hands with a man awaiting a war crimes trial.