In a national television address, Kenyatta said on Wednesday 14 civilians died in the attack claimed by the al-Shabab armed group.
The president said more than 700 civilians were evacuated from the complex.
“The security operation at Dusit complex is over and all the terrorists have been eliminated,” said Kenyatta. “We have confirmation that 14 innocent lives were lost through the hands of these murderers, terrorists with others injured.”
Earlier reports said at least 15 people were killed.
Authorities sent special forces into the hotel to flush out the gunmen. Kenyatta did not say how many attackers were involved.
“We are grieving as a country this morning and my heart – and that of every Kenyan – goes out to the innocent men and women violated by senseless violence. We wish the injured quick recovery and as a nation, we will continue to pray for them,” said Kenyatta.
A police source told AFP news agency two attackers were shot dead on Wednesday morning after a prolonged shootout.
“The two have red bandanas tied around their forehead and bullets strapped around their chest with several magazines each,” the senior police officer said. “Each had an AK-47 which has been secured.”
It was a tormented night for families of those trapped as they waited outside the hotel with sporadic gunfire ringing out, and the rescue of dozens of people at about 3:30am (00:30GMT).
Mourning families and friends gathered at a nearby mortuary on Wednesday. Families who went to the Chiromo morgue were told they could not view bodies until a forensic investigation had been performed, provoking grief and anger.
“My sister is not in any of the hospitals and the last time we spoke she was a bit calm. But suddenly she started crying and shouting and I could hear gunshots and her phone remained on but she wasn’t speaking,” said a woman who gave her name as Njoki.
“We have no doubt her body is here,” she said, weeping.
CCTV footage broadcast on local media showed four black-clad, heavily armed men entering the complex.
According to Kenya’s police chief, Joseph Boinnet, the coordinated assault began at 3pm local time (12:00 GMT) on Tuesday with an explosion that targeted three vehicles outside a bank, and a suicide bombing in the hotel lobby that severely wounded a number of guests.
Hiram Macharia, a marketing executive at LG Electronics, said security officers rescued him and some colleagues from their office two hours after the attack began. But one workmate did not survive.
“One of our colleagues went to the top of the building and his body was found there,” he said.
“Our fighters killed 47 enemies inside the complex. The mujahideen are still in control of most parts of the building complex,” Abdiaziz Abu Mus’ab, the group’s military operations spokesperson, told Al Jazeera on Tuesday.
The attack at DusitD2 was the first in Nairobi since gunmen stormed the city’s Westgateshopping mall in 2013, killing at least 67 people.
On April 2, 2015, another al-Shabab attack killed 148 people at the university in Garissa, in eastern Kenya.
The Westgate attack resulted in many upscale establishments and shopping centres in the capital – including the Dusit – putting up security barriers to check cars and pedestrians.
Like the attack at the Westgate Mall, this one appeared aimed at wealthy Kenyans and foreigners. It came a day after a magistrate ruled three men must stand trial in connection with the Westgate Mall siege.
The US State Department confirmed an American citizen was among those killed in the latest assault, but did not release the victim’s identity. The British high commissioner in Kenya said at least one British national died, without giving details.