The 30-hour siege was the deadliest attack in Mogadishu since the new President Hassan Sheikh Mohamud was elected in May after a protracted political crisis.
The Hayat was a favored meeting spot for government officials and scores of people were inside when a suicide bomber triggered a massive blast, forcing his way onto the premises along with heavily-armed gunmen.
Minutes later, a second explosion struck as rescuers, security forces and civilians rushed to help the injured, witnesses said.
Police said more than 100 people, including women and children, had been rescued during the siege, which began on Friday evening and finally ended around midnight Saturday after security forces bombarded the hotel.
Hamza Abdi Barre also called on Somalis to unite in the fight against the Al-Qaeda-linked group which has been waging a bloody insurgency in the impoverished Horn of Africa nation for more than 15 years.
"There will be accountability in the government... anyone who neglected the responsibility he was entrusted with will be held accountable," Barre told reporters late Sunday.
"There is only one of two choices here, we either allow Al-Shabaab -- the children of hell -- to live, or we live. We cannot live together," said Barre, who was appointed prime minister in June.
He was speaking after visiting a hospital treating wounded victims of the bomb and gun attack on the Hayat Hotel that the health ministry says claimed the lives of 21 people and wounded 117.
"I call on the Somali people to unite to fight against the enemy... so that what they did now will never happen again.
"The fight against them has already started taking place around several locations," he said, without elaborating.
Former Al-Shabaab commander Mukhtar Robow, who is now religion minister in Barre's cabinet, condemned the attack and called on fighters to abandon the group.
"I call on them to repent... I say to them 'you know that this is not right so repent and abandon (Al-Shabaab) and God willing you will survive'," he said.
"Society everywhere should know that their interest lies in uniting to fight against them," he added.
Earlier this month, Washington announced its forces had killed 13 Al-Shabaab operatives in an air strike, the latest since President Joe Biden ordered the re-establishment of a US troop presence in Somalia, reversing a decision by his predecessor Donald Trump.
The Islamist militants, who espouse a strict version of sharia or Islamic law, were driven out of Mogadishu by an African Union force in 2011.
But they still control swathes of countryside and retain the ability to launch deadly strikes, often hitting hotels and restaurants as well as military and political targets.
The deadliest attack occurred in October 2017 when a truck packed with explosives blew up in Mogadishu, killing 512 people.
The Hayat Hotel assault was reminiscent of deadly sieges in neighbouring Kenya, one of the contributors to the AU force.
Al-Shabaab claimed responsibility for a four-day siege at the Westgate shopping mall in Nairobi in September 2013 that killed 67 people and an hours-long attack on an upmarket hotel complex in the city in 2019 that claimed the lives of 21 people.