NAIROBI, Kenya — Fazul Abdullah Mohammed, Al Qaeda’s leader in East Africa and the mastermind of the American Embassy bombings in Kenya and Tanzania, was killed in a late-night shootout at a security checkpoint in Mogadishu, Somalia’s capital, Somali and American officials said Saturday.

The killing, after Mr. Mohammed accidentally encountered a Somali checkpoint, was a major loss for the terrorist network, still reeling from the assassination of its founder, Osama bin Laden, in Pakistan last month.

“Fazul’s death is a significant blow to Al Qaeda, its extremist allies and its operations in East Africa,” Secretary of State Hillary Rodham Clinton said. “It is a just end for a terrorist who brought so much death and pain to so many innocents in Nairobi and Dar es Salaam and elsewhere — Tanzanians, Kenyans, Somalis and our own embassy personnel.”

Mr. Mohammed, who was one of the most wanted men in Africa and had a $5 million bounty on his head from the United States government, and another militant mistakenly drove up to a checkpoint run by Somali government soldiers late on Tuesday night.

Somali officials said that DNA tests carried out in Kenya “by our friends” — suggesting the Central Intelligence Agency, which has been working covertly in Somalia for years — confirmed Mr. Mohammed’s identity on Saturday.

An American official said that the United States identified Mr. Mohammed’s body through DNA analysis. The official would not say what DNA the United States used to compare with the body’s.

“This was lucky,” a Somali security official said Saturday night. “It wasn’t like Fazul was killed during an operation to get him. He was essentially driving around Mogadishu and got lost.”

In recent years, American special forces have killed other high-level Qaeda operatives in Somalia but American officials said Saturday that no Americans were involved, only Somali soldiers.

Mr. Mohammed, a master of disguises and several languages, is widely believed to have helped bring Qaeda-like tactics — suicide bombs, roadside bombs and a pipeline of foreign fighters — to Somalia’s often messy and inchoate Islamist insurgency. According to Somali and American officials, he imported bomb-making materials, raised money in the Arab world for the insurgency and maintained a steady stream of hardened — or at least dedicated — foreign fighters from Afghanistan, Pakistan, Chechnya and even the United States.

He wore two hats, officials said, as the leader of Al Qaeda’s franchise in East Africa and a top field commander for the Shabab, the Somali militant group that started as a homegrown insurgency but has steadily drawn closer to Al Qaeda and expanded its ambitions, carrying out a suicide attack in Uganda last summer that killed dozens. The Shabab are often referred to as the Somali Taliban, sawing off thieves’ hands, stoning adulterers and even yanking out people’s teeth, saying gold fillings are un-Islamic.

Sheik Yusuf Mohamed Siad, a former Somali insurgent leader who joined the government a few years ago, has called Mr. Mohammed “an expert at war.”

Officials with Somalia’s transitional government hope that the killing could be a turning point against the Shabab, who once controlled large tracts of the country but recently have been pushed back. In the past few months, African Union peacekeepers and government-allied forces have been taking the offensive, steadily routing the Shabab in several neighborhoods of Mogadishu and some towns in southern Somalia.

Scores of Shabab fighters have been killed, including many foreigners, and witnesses have described a growing desperation amid Shabab ranks, which might explain how a top Shabab commander could err so fatally as to drive into a heavily armed government checkpoint.

But it was not clear that Mr. Mohammed’s death on Tuesday had weakened the Shabab. On Friday, Somalia’s interior minister was killed in an explosion at his home in the small patch of Mogadishu that the transitional government ostensibly controls. The Shabab claimed it placed a bomb under the minister’s bed. Somali officials said it was a female suicide bomber, possibly the minister’s niece, who was a secret Shabab agent.

An error has occurred. Please try again later.

You are already subscribed to this email.

As worrisome, perhaps, is the reliably dysfunctional state of Somali politics. Just this week, the president and the speaker of Parliament decided to settle a long and bitter feud by firing the prime minister, who was widely considered one of the most professional prime ministers Somalia has had in years. Hundreds of government soldiers rioted in protest, saying the prime minister was the only honest leader in the government.

Many analysts have warned that the Shabab could stage a comeback, unless Somalia’s political leaders get their act together.

Mr. Mohammed, also known as Haroun Fazul, was the third major Qaeda figure killed in the past six weeks. In addition to the fatal shooting of Bin Laden in a Navy Seal raid last month, Pakistani authorities confirmed that Ilyas Kashmiri, a senior operational commander for the group, had been killed by an American drone strike in the northwestern tribal areas early this month.

Mr. Mohammed was instrumental in Al Qaeda’s expansion into Africa. American officials said he was the mastermind of the bombings of American Embassies in Kenya and Tanzania in August 1998, which killed more than 200 people. The attacks were the first by Al Qaeda on an American target.

He was also wanted for bombing an Israeli-owned hotel on the Kenyan coast in 2002, killing 15 people, and an unsuccessful attempt to shoot down an Israeli charter jet there.

He was indicted for the embassy attacks by federal authorities, who offered a $5 million reward for his capture.

Mr. Mohammed, believed to be about 37, was born in the Comoros Islands in the Indian Ocean, and had been living on and off in Somalia since the mid-1990s.

According to an F.B.I. Web page listing the most wanted terrorists, he “likes to wear baseball caps and tends to dress casually. He is very good with computers.”

Late Tuesday night, he and his comrade were driving from Merca, a Shabab-controlled town, to the Shabab-controlled neighborhood of Deynile in Mogadishu. The pair apparently got lost, ending up at the checkpoint on Mogadishu’s outskirts.

Few cars travel after dark in Mogadishu, and it is not unusual for government forces to fire on vehicles that approach their checkpoints, especially late at night. Photos provided by Somali officials showed that several bullets pierced the Toyota’s windshield. Mr. Mohammed was apparently hit at least three times in the torso. No Somali soldiers were hurt.

African Union officials said the soldiers recognized that Mr. Mohammed was a foreigner and, after searching the truck, found $40,000 in cash, along with several dozen Yemeni daggers. Officials said several laptop computers, cellphones and photographs were also found in the truck, which prompted further investigation.

The Somali information minister, Abdulkareem Jama, said Mr. Mohammed was carrying a South African passport showing that he had traveled from South Africa to Tanzania in March, but offering no indication of how he entered Somalia.

His body remains with the Somali national security agency, which is deciding whether to bury it or return it to his family, Mr. Jama said.

A version of this article appears in print on June 12, 2011, on Page A1 of the New York edition with the headline: Somalis Kill Man Behind Bombings Of U.S. Embassies. Order Reprints|Today's Paper|Subscribe