NAIROBI, Kenya — Viewing the deadly siege at a shopping mall in Kenya as a direct threat to its security, the United States is deploying dozens of F.B.I. agents to investigate the wreckage, hoping to glean every piece of information possible to help prevent such a devastating attack from happening again, possibly even on American soil.
For years, the F.B.I. has been closely watching the Shabab, the Somali Islamist group that has claimed responsibility for the Nairobi massacre and recruited numerous Americans to fight and die — sometimes as suicide bombers — for its cause.
The Shabab has already attacked most of the major actors trying to end the chaos in Somalia — the United Nations, Uganda, aid groups, the Somali government and now Kenya. The United States has spent hundreds of millions of dollars bankrolling anti-Shabab operations for years, and there is growing fear that the group could turn its sights on American interests more directly, one of the reasons the Obama administration is committing so many resources to the investigation in Kenya.
“We are in this fight together,” said Robert F. Godec, the American ambassador to Kenya. “The more we know about the planning that went into this, the way it was conducted, what was used, the people involved, the better we can protect America, too.”
Less than a day after the bloody standoff ended, more than 20 F.B.I. agents wearing flak jackets and helmets were combing through the wreckage strewn across the steps of the mall. Dozens more agents will be headed to Nairobi, American officials say. Some of them are members of the New York Joint Terrorism Task Force squad that investigates extremist groups operating in the Horn of Africa, a law enforcement official said.
Over the next few days, agents, including a full Evidence Response Team, will be collecting D.N.A., fingerprints and other biometric information, poring through surveillance footage and examining guns, laptops, cameras and computers — anything to gain insights into how the attack was carried out and the hierarchy, planning and structures behind the group, especially if they have any ties back to the United States.
American officials are mindful that Kenya, one of its closest allies in Africa, has become a precarious buffer zone between the United States and Islamist militants who have declared foreigners legitimate targets in their war.
The American government has learned the hard way what happens if it does not contain groups responsible for faraway attacks. In 1998, the then-relatively unknown group called Al Qaeda simultaneously attacked the United States embassies here and in Tanzania, killing hundreds and following up a few years later with the terrorist attacks of Sept. 11, 2001.
The Shabab militant group, which has pledged allegiance to Al Qaeda and taken responsibility for killing more than 60 civilians at the mall, is considered an especially dangerous threat because more than two dozen young American men are already learning terrorist tactics in Somalia. So far, this has been a one-way pipeline, but the fear is that some battle-hardened militants could come home with their American passports to strike on American soil.
“You never know when a terrorist attack in a faraway place could be a harbinger of something that could strike at the United States,” said Daniel Benjamin, a former Obama administration counterterrorism official. On Kenya, he said, “It’s a country that has a long history of being attacked by terrorists that are of real concern to the United States.”
Compounding matters, relations between the United States and Kenya had grown frosty before the attack because Kenya’s president has been indicted on charges of crimes against humanity by the International Criminal Court. American officials here were trying to keep their distance from him, but now the two sides must work closely together.
As the mall attack showed, militants would not need to reach the United States to strike hard at American interests. Several Americans were injured in the four-day siege, though none were killed. French, British, Canadians, Chinese, Indians and many others died, most of them Kenyan.
The American government is concerned that the Shabab could target the thousands of Americans living in Kenya, working for companies like General Electric, the embassy or the enormous United Nations office here in the cosmopolitan capital. Tens of thousandsof other Americans visit the nation’s game parks, beaches and other tourist attractions every year, according to the Kenyan government.
American officials say that several of the attackers may have escaped, posing as civilians and fleeing in the mayhem. The worry is that they may be planning future attacks here in Nairobi.
Wednesday was Day 1 of an investigation that may take weeks, even months, with the first priority establishing the identities of the 10 to 15 attackers who burst into the mall on Saturday with automatic weapons, shooting some people at random, questioning others about their religion and ruthlessly sorting individuals for execution.
Kenyan officials have said that some of the attackers may have been Somali-Americans, but Attorney General Eric H. Holder Jr. said Wednesday that there had been no confirmation of that. Another question is whether a British woman, Samantha Lewthwaite, known as the White Widow, was among the assailants.
Part of the mall was destroyed during the three-day effort to dislodge the terrorists, who had holed up in a supermarket with belt-fed machine guns that officials say were sneaked into the mall days before with the help of a colluding employee.
“The next phase really is making sure we know what’s under the rubble,” said a Kenyan government spokesman, Manoah Esipisu. “Forensic people need to be able to clear that rubble and examine the evidence beneath it.”
The massacre plot was hatched weeks or months ago on Somali soil by the Shabab’s “external operations arm,” according to American security officials. A team of English-speaking foreign fighters was carefully chosen for the target: Westgate, a gleaming upscale mall popular with expatriates and Nairobi’s rising middle class.
Kenya is considered one of the most promising countries in Africa and has become a hub for American interests, including the effort to contain Islamist extremism in the region, putting pressure on the United States to repair its strained relations with Kenya’s president, Uhuru Kenyatta.
“This incident has literally put Kenyatta and his deputy in the center stage of the war on terror,” said Peter Kagwanja, the chief executive of the Africa Policy Institute, a nonprofit research organization in Nairobi. “America and the world have to contend with the aftermath of Nairobi.”
The United States urgently wants to decode the tactics of the assault. There is growing concern about the ease with which a few determined militants armed with automatic weapons could storm into a crowded area, kill many people very quickly and hold off government forces for so long. After the Mumbai killings in 2008, the F.B.I. sponsored training sessions for the hotel industry and other groups that could be soft targets for such attacks.
“One of the misconceptions is that we can let Al Qaeda or other terrorist groups stay abroad and not fight them there, and that we would be safe at home,” said Katherine Zimmerman, senior analyst at the Critical Threats Project of the American Enterprise Institute. “That’s really proven not to be the case.”
Eric Schmitt contributed reporting from Washington, and William K. Rashbaum from New York.