Security forces in Nairobi prevailed on Tuesday against Islamic insurgents in a four-day gunbattle that devastated a popular shopping mall, shook a nation and pointed to a new front line in Africa's fight against terrorism.

In an address to the nation on Tuesday night, Kenyan President Uhuru Kenyatta said five militants had been killed in an operation that culminated with massive explosions that brought down three floors of the upscale Westgate mall.

ENLARGE

Relatives of a victim weep after identifying his body at Nairobi's morgue.
Associated Press

Efforts to retrieve bodies and identify the assailants were expected to begin at daylight Wednesday, soldiers involved in the operation said.

Mr. Kenyatta also said 11 suspects were in police custody. He said an investigation was also under way to determine whether any of the attackers had come from the U.S. or Britain, as unconfirmed intelligence reports had suggested. It wasn't immediately clear whether hostages had also died after the floors collapsed.

Residents awoke to gunfire around Nairobi's Westgate Mall on the fourth day of a standoff between terrorists and Kenyan forces. The WSJ's Heidi Vogt gives us the latest details emerging about the assailants.

The assault on Westgate mall marked the deadliest single attack in the capital since the 1998 U.S. Embassy bombing, in which more than 200 people died. The assailants who seized the Nairobi shopping mall killed 61 civilians and six security forces, Mr. Kenyatta said. The death toll could rise as bodies are pulled out of a portion of the building that collapsed on Tuesday.

Mr. Kenyatta, in his address, declared three days of national mourning. "We have been badly hurt and feel great pain and loss," he said. "In resolutely looking forward and never turning back, we have defeated our enemies."

But the grisly attack—on a target that pulled in Nairobi's cosmopolitan elite—showed how easily Islamic insurgents can pierce a country's defenses. Neither the Kenyans nor any of their international partners have said they had any indication an attack of this scale was imminent. Some experts said the response also showed how the government of Mr. Kenyatta, who was elected this year, is still finding its feet on counterterrorism issues.

"The president is really brand new at this and just doesn't have a lot of experience in big time governance at any level," said Henry Crumpton, a former top counterterrorism official at the State Department and the Central Intelligence Agency who worked in Kenya.

That inexperience may have prolonged the attack, said Daniel Benjamin, a former top State Department counterterrorism official. "Part of the reason the attack was so devastating is the Kenyans' lack of experience with a situation like this."

Similar mass attacks on civilians have played out in other pockets of the African continent, including Nigeria and Somalia, home to two of the continent's most ruthless militancies, Boko Haram and al-Shabaab. The governments of these countries, as well as Kenya, have sought from the U.S. and other governments more counterterrorism assistance.

As the siege on the mall unfolded, the Somali militant group al-Shabaab claimed responsibility. On Tuesday, it posted a Swahili praise song online to honor its slain militants. The group said it had targeted Kenya partly because of Kenyan peacekeepers fighting al-Shabaab in Somalia.

"You could have avoided all this and lived your lives with relative safety," a message from a Twitter account purported to be al-Shabaab's said on Tuesday. "Remove your forces from our country and peace will come."

ENLARGE

Kenyan President Uhuru Kenyatta, center, speaking during a press conference about an attack on the Westgate shopping mall in Nairobi.
AFP/Getty Images

The assault started shortly before 12:30 p.m., after a grenade exploded on the rooftop parking lot where a children's cooking competition was being taped for television. The presenter, a prominent Kenyan radio personality, was killed along with many others.

At almost the same time, assailants armed with assault rifles and grenades stormed the mall's main ground-floor entrance and its basement parking garage, firing as they came. People dove for cover in restaurants and ran for stairwells. More grenades went off.

Some people rushed for the doors only to run into gunfire. Others streamed out of fire exits and, later, crawled out of air-conditioning ducts.

At a second-floor restaurant, Uche Kaigwa-Okoye spent the next five hours packed in a bathroom stall with three other people, trying to stay quiet as they heard guns firing on the other side of the door.

"They must have been shooting right next to us," Mr. Kaigwa-Okoye said. "When we were rescued, I saw the glass and the shells outside the door."

ENLARGE

Police arrived, first believing they were responding to a brazen armed robbery. As they pushed into the mall, the nature of the attack became clear. As the military arrived, people trapped inside the mall by gunfire made frantic calls to friends, trying to find out if it was safe to run. Insurgents went store-to-store and restaurant-to-restaurant, often shooting people on sight; sometimes they first asked people to prove that they were Muslim.

"They were questioning people, and they said, 'If you are Muslim you are on the safer side, but if you are Hindu or Christian you will be killed,'" said 26-year-old Edwin Omoding, who works in the stockroom of the mall's supermarket.

Those who were still in hiding sent text messages to each other with Islamic phrases to recite if questioned. At least 39 people were confirmed killed by the end of the day.

Sporadic gunfire and explosions continued through Sunday and Monday and the flow of escapees slowed. Even as the Kenyan government expressed confidence about gaining control of the building, the shooting continued. By Monday afternoon, a large fire engulfed one side of the building.

Still, the Kenyan government said its operation had successfully rescued more than 1,000 people. From the early hours Tuesday, officials tweeted that they believed all the hostages had been freed and appeared ready to declare victory.

Then before dawn on Tuesday, Kenyan police tweeted: "We have triumphed."

In an interview on U.S. channel PBS "NewsHour," Amina Mohamed, Kenya's Foreign Minister, said that two or three Americans were among the militants who attacked Nairobi's Westgate Mall, although this hasn't been independently verified. Photo: Getty Images

But victory over the militants eluded the security forces. By Tuesday morning, gunfire had erupted again. It continued sporadically throughout the day and the siege appeared set to drag through another long night. A military official said the militants were using the remaining hostages as human shields. The Kenyan military requested 100 body bags to be brought to the site.

In a fierce final exchange as night fell Tuesday, Kenyan soldiers fired rocket-propelled grenades at insurgents, triggering the explosives that the militants had rigged inside the building, said a group of soldiers outside the mall.

The massive blasts caused three of the mall's floors to collapse upon each other. Although the structure of the building remained, the collapsed floors made survival for anyone inside unlikely, a lieutenant in the Kenyan Defense Forces said. The lieutenant said he hadn't seen any hostages during the final stages of the operation.

The lieutenant said it wasn't possible to see inside the building because power systems had been destroyed. Search and recovery of bodies could only begin at daylight, he said.

In his address, Mr. Kenyatta didn't answer a question that has loomed over the siege: Who were the militants? He mentioned unconfirmed intelligence reports that two or three Americans were involved as well as a British woman, but said an investigation into the nationalities of the attackers was continuing.

U.S. officials are trying to cut through the muddled picture. They are still working to confirm whether Americans were among the attackers. Part of the difficulty in determining whether Americans were among the assailants is matching the names provided by the Kenyans with known individuals, a senior Obama administration official said.

Officials have sought to match identifies with data in U.S. databases, such as passport information, but so far they haven't been able to confirm claims Americans were involved. Part of the challenge is simply discerning proper spellings of names.

The continuing nature of the attack has also delayed confirmation, the senior administration official said, adding, "How would you confirm it before you have bodies?"

Americans have joined jihadist groups over the last several years, and in 2007 through 2009, there was a surge of Somali-Americans joining up with al-Shabaab. Lately, more Americans have been drawn to other terror hot spots like Yemen and Syria.

Also adding to the confusion, the senior administration official said, is the major role social media, like Twitter, has played in circulating unformed reports and rumors. "The rumors you hear just get amplified," the official said.

Analysts have said that the resources involved in mounting this size of an attack in Kenya would be difficult for al-Shabaab—suggesting the al Qaeda affiliate might be working more closely with the world-wide terror organization to receive help with recruits, funding and logistics.

"They can't just walk into Westgate from rural Somalia," said Cedric Barnes, the Horn of Africa director for International Crisis Group.

After the operation, columns of wearily-looking Kenyan troops strolled out of the gates of the luxury Nairobi shopping mall. No more gunfire; no more deafening explosions; no more hovering helicopters. In the quiet night, the troops simply strolled down the dark streets.

"We are always in the line of fire," said an army sergeant pointing into the direction of the mall. "To get out of this safely is a miracle."

—Peter Wonacott in Nairobi and Devlin Barrett in Washington contributed to this article.

This copy is for your personal, non-commercial use only. Distribution and use of this material are governed by our Subscriber Agreement and by copyright law. For non-personal use or to order multiple copies, please contact Dow Jones Reprints at 1-800-843-0008 or visit www.djreprints.com.