NAIROBI, Kenya - Masked gunmen stormed into a fancy, crowded mall in Nairobi on Saturday and shot dead at least 39 people and wounded more than 150 in one of the most chilling terrorist attacks in East Africa since Al Qaeda blew up two American embassies in 1998.
Parents hurled their bodies over their children, people jumped into ventilation shafts to save themselves, and shoppers huddled behind the plastic mannequins of designer clothing stores as two squads of gunmen believed to be linked to a Somali terrorist group moved through the mall, shooting shoppers in the head. Hours later, the mall's gleaming floors were smeared with blood as police officers dashed through the corpse-strewn corridors, trying to find the assailants.
A standoff with the attackers, who were reported to be heavily armed and holding an unknown number of hostages, continued as the sun rose on Sunday.
The mall, called Westgate, is a symbol of Kenya's rising prosperity, an impressive five-story building where Kenyans can buy expensive cups of frozen yogurt and plates of sushi. On Saturdays, it is especially crowded, and American officials have long warned that Nairobi's malls were ripe targets for terrorists, especially Westgate, because a cafe on the ground floor, right off the street, is owned by Israelis.
Fred Ngoga Gateretse, an official with the African Union, was having coffee at that cafe around noon when he heard two deafening blasts. He cowered on the floor and watched eight gunmen with scarves twisted over their faces firing at shoppers and then up at Kenyan police officers who were shooting down from a balcony as panicked shoppers dashed for cover. "Believe me, these guys were good shooters," Mr. Gateretse said. "You could tell they were trained."
Several witnesses said the attackers had shouted for Muslims to run away while they picked off other shoppers, executing them one by one. The mall, one of Nairobi's most luxurious, with glass elevators and some of the most expensive shops in town, is also popular with expatriates. It has served as the place for a power lunch, to catch a movie, to bring children for ice cream.
Four Americans were believed to have been injured in the attack, American officials said, and none were reported killed. Secretary of State John Kerry, who called the attack "a heartbreaking reminder that there exists unspeakable evil in our world," said the wife of a local employee of the American government was among the dead. Two Canadians, one of them a diplomat based in Nairobi, and two French citizens were killed, their governments said.
A confidential United Nations security report on Saturday described the attack as "a complex, two-pronged assault" with two squads of gunmen dashing into the mall from different floors at the same time and opening fire.
The Shabab, an Islamist militant group based in Somalia, took responsibility for the attack, saying it was revenge for Kenya's military operations in Somalia, which began nearly two years ago. "Kenya will not get peace unless they pull their military out of Somalia," said Ali Mohamoud Rage, the Shabab's spokesman, in a radio address. The Shabab also sent out a barrage of buoyant Twitter messages, bragging about the prowess of their fighters before Twitter abruptly suspended the account late Saturday. Later, a new one was set up.
Kenya's president, Uhuru Kenyatta, called the terrorists cowards and said Kenya would remain "as brave and invincible as the lions on our coat of arms." He also sounded a somber note, pleading with Kenyans to give blood , and said he had lost "very close family members in this attack," though he did not specify further.
In addition to the 39 people killed, who included women and children, Mr. Kenyatta said, more than 150 were wounded. Government officials said the wounded ranged in age from 2 to 78.
By Saturday night, Kenyan commandos had cornered several of the assailants on the third floor of the mall, witnesses said. Western officials said they expected that the assailants would fight to the death, though the Kenyan news media reported that one wounded gunman had been captured and died in a hospital. Several witnesses also said one of the assailants was a woman.
Throughout the day, as the police cleared sections of the mall, terrified shoppers emerged with their hands up and collapsed in each other's arms.
Early Sunday, the government said that the mall's upper levels had been secured and the gunmen contained in one place, but that hostages remained in several locations.
Witnesses described attackers using AK-47 and G-3 assault rifles and throwing grenades.
Vivian Atieno, 26, who works on the first floor of the mall, described "intense shooting," starting around 11 a.m., before she escaped through a fire exit.
Haron Mwachia, 20, a cleaner at the mall, said he had survived by climbing over a wall. "I heard several gunshots and managed to run away," he said. "I've never seen anything like it."
Kenya serves as the economic engine of East Africa, and while it has been mostly spared the violence and turmoil of many of its neighbors, it has had other terrorist attacks. In 1998, Al Qaeda killed more than 200 people in an enormous truck bombing that nearly leveled the American Embassy in downtown Nairobi, while simultaneously attacking the American Embassy in Dar es Salaam, Tanzania. Islamist terrorists also struck an Israeli-owned hotel on Kenya's Indian Ocean coast in 2002 and fired missiles at an Israeli airliner.
More recently, the Shabab have put Kenya in its cross hairs, especially after Kenya sent thousands of troops into Somalia in 2011 to chase the Shabab away from its borders and then kept those troops there as part of a larger African Union mission to pacify Somalia. The Shabab have attacked churches in eastern Kenya, mosques in Nairobi and government outposts along the Kenya-Somalia border.
But this was the boldest attack yet. Within minutes, as the gunmen opened fire with assault rifles, Westgate was plunged into mayhem and carnage. People ran out screaming, and victims soaking in their own blood were wheeled out in shopping carts. Bodies were still sprawled on the mall's front steps hours afterward, and woozy shoppers continued to emerge from the stores where they had been hiding.
"This is such a shock," said Preeyam Sehmi, an artist, as she stumbled out of the mall, past a phalanx of Kenyan soldiers, after five hours of hiding. "Westgate was such a social place."
Ilana Stein, a spokeswoman for Israel's Ministry of Foreign Affairs, said the attack took place near the ArtCaffe, an Israeli-owned coffee shop and bakery popular with foreigners that is one of 80 businesses in the mall. Ms. Stein said that one Israeli had been lightly injured, that three others had escaped unharmed and that Israelis had not been specifically targeted. "This time, the story is not about Israel," Ms. Stein said.
As night fell, hours after the attack began, Kenyan police helicopters hovered overhead while soldiers in flak jackets and helmets jogged single file into the mall, faces grim, guns cocked. The flashing lights of ambulances lighted up the mall's facade. Gunshots continued to ring out well past dark, though the Kenyan authorities did not provide much information about what was happening inside the mall. Several Kenyan soldiers were later brought out grimacing from what appeared to be gunshot wounds.
Before its Twitter account was shut down, the Shabab sent out a message, saying the fighters in the mall would never give up.
"There will be no negotiations whatsoever at #Westgate," the message said.
The Shabab, who have pledged allegiance to Al Qaeda, used to control large parts of Somalia, imposing a harsh and often brutal version of Islam in their territory. They have beheaded civilians and buried teenage girls up to their necks in sand and stoned them to death. But in the past two years, the African Union forces, including the Kenyans, have pushed the Shabab out of most of their strongholds. The worry now, current and former American officials said Saturday, is that this attack could be the start of a comeback.
"I think this is just the beginning," said Rudy Atallah, the former director of African counterterrorism for the Pentagon. "An attack like this gives them the capability to recruit, it shows off their abilities, and it demonstrates to Al Qaeda central that they are not dead."
Jeffrey Gettleman reported from Nairobi, and Nicholas Kulish from Goma, Democratic Republic of Congo. Reporting was contributed by Reuben Kyama and Tyler Hicks from Nairobi; Jodi Rudoren from Jerusalem; Mark Mazzetti from Washington; and Mohamed Ibrahim from Mogadishu, Somalia.
This article has been revised to reflect the following correction:Correction: September 21, 2013
Because of an editing error, an earlier version of this article misspelled the given name of the president of Kenya. He is Uhuru Kenyatta, not Uruhu.