President Uhuru Kenyatta said that Kenya's troops had overcome the terrorists who besieged the upmarket shopping mall in Nairobi.
Kenyatta said that five al-Shabaab militants were killed by security forces in the military operation to retake control of the Westgate shopping centre. Another 11 were apprehended and were in police custody, he said.
"We have shamed and defeated our attackers. That part of our task was completed," Kenyatta said.
The president said that a total of 72 people, including six security officials, were killed in the four-day siege he described as an "encounter with evil".
"Fellow Kenyans, we have been badly hurt and feel great pain and loss, but we have been brave, united and strong," he said. "Kenya has stared down great evil and triumphed."
Three floors of the four-story building collapsed during the rescue operation and at least three bodies were still trapped under the rubble, he said.
Numerous explosions occurred throughout the military operation. Security officials said they had blown up part of the roof to get inside.
Kenyatta declared three days of national mourning and vowed that the country would continue to fight terrorism in east Africa. "This cowards will meet justice," he said.
The president could not confirm intelligence reports that three Americans and one Briton were among the attackers. The foreign minister had said earlier that "two or three" Americans and a British woman were among the perpetrators.
Amina Mohamed told US TV programme PBS Newshour that the Americans were 18 or 19 years old and came from "Minnesota and one other place".
The British woman was widely believed to be Samantha Lewthwaite, 29, the so-called White Widow who was married to Germaine Lindsay, one of the 7/7 London bombers. She has been on the run in east Africa since allegedly taking part in a plot to detonate a bomb in the Kenyan city of Mombasa in 2011.
Al-Qaida-linked rebel group al-Shabaab, which has its base in Somalia, claimed responsibility for the mall attack.
The group said that it targeted Nairobi in retaliation against Kenya's involvement in an African Union military operation to oust it from Somalia and focused on Westgate in particular because of its large number of Jewish and American-owned stores.