A senior figure in the Somali militant group al-Shabab has told the BBC it carried out a deadly attack on a shopping centre in neighbouring Kenya.
Kenyan President Uhuru Kenyatta said 39 people had been killed, including some of his family, and 150 were injured.
Al-Shabab said the attack was in response to Kenyan troops in Somalia.
There are about 4,000 Kenyan troops in the south of Somalia, where they have been fighting the militants since 2011.
On its Twitter feed, al-Shabab – which has links to al-Qaeda – said it was behind what it called the â€œWestgate spectacleâ€.
In his TV address, Mr Kenyatta said security forces were â€œin the process of neutralising the attackers and securing the mallâ€.
He went on: â€œWe shall hunt down the perpetrators wherever they run to. We shall get to them and we shall punish them for this heinous crime.â€
He said he had â€œpersonally lost family members in the Westgate attackâ€.
As night fell in Nairobi, two contingents of army special forces troops are reported to have moved inside the mall.
A police officer inside the shopping centre told Reuters that the remaining gunmen were barricaded inside a Nakumatt supermarket, one of Kenyaâ€™s biggest chains.
In the early hours of Sunday morning, the Kenya National Disaster Operation Centre said the number of hostages was â€œstill unknown, but they are in several locationsâ€.
â€œThe gunmen have been contained in one location, but there are hostages elsewhere in the vicinity who cannot access the exit,â€ the centre said on its Twitter feed.
Upper levels of the mall had been secured, it said.
The attackers entered the Westgate centre at about 12:00 local time (09:00 GMT), throwing grenades and firing automatic weapons. A childrenâ€™s day event was being held at the time.
The BBCâ€™s security correspondent Frank Gardner says a security source told him that at least one of the attackers was a woman who appeared to have some kind of leadership role.
Our correspondent says that it is unclear how many civilians are hostages and how many are in hiding.
Al-Shabab said on Twitter that the Kenyan government wanted to negotiate an end to the Westgate attack. But officials have told the BBC they intend to hunt the gunmen down.
One gunman was arrested and died of his wounds, Kenyan officials told the BBC. Four other gunmen were arrested.