Following the blasts Saturday afternoon, gunmen laid siege to the Nasahablood 2 hotel, which is popular with government officials.

During the 10-hour siege, which came to an end early Sunday, one of the militants blew himself up causing an unknown number of casualties among security forces, police officer Mohamed Dahir told dpa.

Among the 25 confirmed dead were Abdinasir Mohamed Garane, a former deputy minister of livestock, and a senior police commissioner.

More than 30 people, including a government minister and a prominent cleric, were rescued, Dahir said.

On their radio station, insurgent group al-Shabaab claimed responsibility for the attack.

Six militants are confirmed to have been involved, two of whom blew themselves up and another who was shot dead by security forces, according to Abdiasis Ali Ibrahim, a spokesman at the Ministry of National Security.

The remaining three have been captured by the soldiers, he added.

Much of the hotel siege took place in the pitch dark after the electricity was cut.

Saturday's attack came two weeks after more than 350 people were killed in a massive truck bombing on a busy Mogadishu street in Somalia's worst-ever attack.

Somalia President Mohamed Abdullahi Mohamed released a statement after the Nasahablood attack saying the incident will not stop his government from tackling terrorists.

"I share the sadness with the families and friends as we are again witnessing another deadly attack here in Mogadishu," he added.