(CNN) -- The Al-Shabaab assault on a mall in Nairobi, Kenya, is alarming for its audacity, its scale and the sophisticated planning that went into it. Both the choice of target and method of attack exactly fit the new al Qaeda playbook.
Few counterterrorism experts are surprised that the Somali group launched another attack in the Kenyan capital. It has threatened to take revenge ever since Kenyan forces entered Al-Shabaab's heartland in southern Somalia. Small-scale attacks, frequently with hand grenades, have already brought bloodshed to Nairobi's streets. Back in September of last year, Kenyan authorities said they had disrupted a major plot to attack public spaces in Nairobi in its final stages of planning. Authorities also broke up a plot by the group against Western tourists in the city in late 2007.
But the scope of the assault on the Westgate Mall -- and especially its eerie similarities to the attack in Mumbai, India, in 2008 -- show that Al-Shabaab has taken its ability to strike outside Somalia to a new level.
Only once before has the group caused such carnage in East Africa, when bombers attacked bars and restaurants in the Ugandan capital, Kampala, on the night of the World Cup Final in 2010. More than 60 people were killed. Al-Shabaab said the attacks were in retaliation for Uganda's leading role in the African Union force supporting Somalia's weak government in Mogadishu.
But the attack on the Westgate Mall is very different, involving perhaps 10 or more heavily armed assailants, using multiple entrance points to lay siege to a high-profile venue in an upscale neighborhood. The assault then evolved into a hostage-taking to garner maximum publicity.
Al-Shabaab says the attack took months of planning and training, and as it unfolded the group kept up a running commentary on its Twitter feed.
"The Mujahideen entered #Westgate Mall today at around noon and are still inside the mall, fighting the #Kenyan Kuffar (infidels) inside their own turf," it said.
Al Qaeda Template
The operation ticks the boxes that al Qaeda leader Ayman al-Zawahiri listed in a message published just over a week ago.
1. Ensure the target is Western. The Westgate Mall has several Israeli establishments and is popular with expatriates. Those killed include three British citizens, two French nationals and two Canadians, their governments said. In his September 13 message, al-Zawahiri warned against attacks on non-Western states unless the regime was part of "the American forces." Kenya, with its long tradition of pro-Western governments and close relationships with Western militaries, fits that bill.
2. Take hostages where possible. Al-Zawahiri recommended taking "the citizens of the countries that are participating in the invasion of Muslim countries as hostages so that our prisoners may be freed in exchange."
3. Try to avoid Muslim casualties. Al-Shabaab claimed on its Twitter feed that the gunmen escorted Muslims out of the mall, before turning on the "disbelievers" inside. Witnesses said the gunmen at the Westgate tried to identify Muslims by asking shoppers the name of Mohammed's mother. They shot those who didn't know.
Nairobi is vulnerable to Al-Shabaab attacks not least because of the large Somali community, many of them refugees from the country's long-running clan warfare, that lives in the Eastleigh district. Known as "little Mogadishu," Eastleigh is now home to an estimated 250,000 Somalis. And Al-Shabaab is well established there, raising money, finding recruits and setting up safe houses.
Al-Shabaab also has an ally in the militant Kenyan group al Hijra, formerly the Muslim Youth Center, which has a strong presence in Eastleigh and in the coastal city of Mombasa. Investigators will be examining whether al Hijra played a role in the attack on the Westgate mall. Kenyan al Hijra militants are suspected to have been responsible for several of the small-scale terrorist attacks that have hit the country.
This is a worrying trend, analysts say. While Al-Shabaab's Somali fighters are not used to operating abroad, non-Somali East Africans have been training with the group in southern Somalia. Al Hijra is the most potent outgrowth of that training. Founded in an Eastleigh mosque in 2008, al Hijra took advantage of growing radicalization among a minority of Kenya's 4.3 million Muslims to build a significant presence in Nairobi and Mombasa. Investigators established the group had close links to the attacks in Kampala in July 2010. According to the U.N. Monitoring Group on Somalia, most of the operatives who conspired in the attack were Kenyan and close to al Hijra leaders.
A crackdown against al Hijra by Kenyan authorities, helped by the United States, has weakened the group. According to a 2013 United Nations report, "Al Hijra members were plagued by unexplained killings, disappearances, continuous 'catch and release' arrest raids and operational disruptions." But al Hijra is far from defeated. According to the U.N. report, it has established links with Al-Shabaab affiliates elsewhere in East Africa and is enlisting the services of fighters returning from Somalia "to conduct new and more complex operations." Its leadership has become closer to al Qaeda through figures such as Abubakar Shariff Ahmed, known as "Makaburi," who is said to favor large-scale attacks in Kenya in support of Al-Shabaab.
Al-Shabaab has other valuable alliances in the region, including the government of Eritrea, which sees it as a useful ally against its arch-enemy Ethiopia. A United Nations Monitoring Group reported in 2011 that financial records and shipping movements indicated Eritrea's support for Al-Shabaab went far beyond the humanitarian.
In a 400-page report, it concluded that Eritrea's relationship with Al-Shabaab seemed designed to "legitimize and embolden the group rather than to curb its extremist orientation or encourage its participation in a political process."
Al-Shabaab has also established a relationship with al Qaeda in the Arabian Peninsula in Yemen, from which it obtains weapons and training, according to counterterrorism officials and former members of both AQAP and Al-Shabaab. One former jihadist tells CNN the relationship began in 2008 when he linked up a senior figure in Al-Shabaab, Ahmed Warsame, with the Yemeni cleric Anwar al-Awlaki.
In September 2011, the U.S. Africa Command warned that Al-Shabaab, Boko Haram in NIgeria and al Qaeda in the Islamic Maghreb were trying to synchronize their efforts to launch attacks on U.S and Western interests.
The Kenyan capital became much more vulnerable to retaliation when Kenyan troops and tanks, supported by airstrikes, moved into Somalia in October 2011 in response to growing cross-border violence. Al-Shabaab immediately warned that the incursion would have "cataclysmic consequences."
What was meant to be a limited engagement dragged on. It took a year for Kenyan forces to capture the port of Kismayo, but in doing so they dramatically raised the stakes for Al-Shabaab. According to the U.N., Al-Shabaab used to collect an estimated $35 million to $50 million annually in custom tolls and taxes on businesses in Kismayo and two secondary ports higher up the coast -- about half its entire estimated annual income.
Its expulsion from Kismayo changed the dynamics for Al-Shabaab. Previously the group held off plotting large-scale attacks in Kenya because of Kenya's importance for recruitment, logistics and fund-raising. Al-Shabaab commanders realized a crackdown by law enforcement on Somali interests in Kenya would be devastating to the Somali business community, creating a backlash against it in Somalia. But after they lost control of Kismayo, the gloves came off.
In March, Al-Shabaab warned Kenyans they would not "sleep safely" in Nairobi as long as their soldiers were in Somalia. And in the midst of the siege, the group tweeted: "For long we have waged war against the Kenyans in our land, now it's time to shift the battleground and take the war to their land."
"The attack at #WestgateMall is just a very tiny fraction of what Muslims in Somalia experience at the hands of Kenyan invaders," another tweet said.
It's notable that Al-Shabaab was able to plan and train for such a sophisticated attack despite losing much territory in southern Somalia and around the capital, Mogadishu. As it has lost ground, the group has resorted to suicide bombings. Earlier this month it carried out a bomb attack against a restaurant popular with Westerners in Mogadishu, killing more than a dozen people.
A U.N. report issued in July noted that Al-Shabaab "has shifted its strategic posture to asymmetrical warfare in both urban centres and the countryside" but added that it "continues to control most of southern and central Somalia." The report estimated the military strength of Al-Shabaab at about 5,000 fighters, with a functioning chain of command, and said it had "preserved the core of its fighting force and resources."
After years of infighting and feuds, the Nairobi attack may also confirm the ascendancy of Al-Shabaab's most militant faction and its leader Mukhtar Abu al Zubayr (aka Ahmed Abdi Godane). Zubayr attended a madrassa in Pakistan as a young man and merged the group with al Qaeda in February 2012. He sees Al-Shabaab as part of al Qaeda's global jihad.
Dissenters have defected or been killed. Sheikh Hassan Dahir Aweys of Al-Shabaab's old guard surrendered to Somali authorities. And earlier this month Zubayr reportedly ordered the killing of two Western militants who were critical of his leadership style and had aligned themselves with Aweys -- Omar Hammami and Osama al Brittani. Hammami was an American from Alabama who had become a prominent mouthpiece for Al-Shabaab before publicly criticizing Zubayr last year.
Zubayr's increasingly tight grip on Al-Shabaab -- thanks to his ruthless use of the group's intelligence wing in hunting down opponents -- appears to have forestalled the collapse of Al-Shabaab, and may have made it more dangerous.
Zubayr has threatened a direct attack on the United States, and last year the U.S. offered a $7 million reward for information locating him. It would be very surprising if the attack in Nairobi did not receive his blessing, and it may be a sign of things to come as Al-Shabaab takes its war to other parts of East Africa.
Of more immediate concern to Kenyan authorities, in a country where political violence can explode quickly, is a likely backlash against Somali and Kenyan Muslims, which could create a new cycle of radicalization and unrest.