The gunmen were "pinned down" after hours of painstaking evacuations, with police going shop to shop to secure the Westgate shopping mall, a security source told AFP.
"The attackers have been isolated and are pinned down in an area on one of the floors. The rest of the mall seems to be secure," a security source told AFP at the scene.
Senior police sources said they believed a well-organised "terror gang" numbering around 10 was behind the assault on the shopping centre, which was packed with around 1,000 shoppers when it was besieged at midday.
"The death toll is now standing at 30. This includes those who have died at the scene and at the hospital," a senior police official told reporters. The Red Cross confirmed the figure and said another 60 had been wounded in the attack.
The Kenyan government, which has troops battling Islamist Shebab insurgents in neighbouring Somalia, said it was too early to say who was responsible.
Police at the scene said a suspect wounded in the firefight had been detained and taken to hospital under armed guard.
"We have reports there were up to 10 or so attackers and they appeared to be wearing a similar outfit, and others covered their faces," a police official said. "The pattern of the attack and the way they were speaking to their targets clearly point to a well-planned attack by a terror gang."
Kenyan troops could be seen moving around and inside the shopping centre while special forces had joined the operation.
