Jay Patel, who sought cover on an upper floor in the mall when shooting began, said that when he looked out of a window onto the upper parking deck of the mall he saw the gunmen with a group of people. Patel said that as the attackers were talking, some of the people stood up and left and the others were shot.
The attack was carried out by terrorists, said Police Chief Benson Kibue. He did not specify a group. He said it was likely that no more than 10 attackers were involved.
Somalia's president said his nation knows "only too well the human costs of violence like this" as he extended prayers to those in Kenya.
"These heartless acts against defenseless civilians, including innocent children, are beyond the pale and cannot be tolerated. We stand shoulder to shoulder with Kenya in its time of grief for these lives lost and the many injured," President Hassan Sheikh Mohamud said.
The gunmen carried AK-47s and wore vests with hand grenades on them, said Manish Turohit, 18, who hid in a parking garage for two hours.
"They just came in and threw a grenade. We were running and they opened fire. They were shouting and firing," he said after marching out of the mall in a line of 15 people who all held their hands in the air.