Seven al-Shabab militants who attacked a high-security prison in Somalia's capital have all been killed, the country's government has reported.

A major explosion and heavy gunfire were heard from Godka Jilicow — a detention center housing al-Shabab members — in Mogadishu on Saturday evening.

Al-Shabab claimed responsibility for the attack, asserting that they had released 'all the Muslim prisoners' from the facility and inflicted significant casualties on the prison's guards.

To gain entry, the militants disguised themselves as soldiers, as reported by the government-run news agency Sonna Live on Sunday.

The government has not disclosed how many security personnel were casualties during the incident, although they expressed their condolences to the fallen heroes' families.

Al-Shabab also kept silent on the number of militants who were killed.

The confrontation began at around 16:40 local time (13:40 GMT) and raised alarms about security lapses in one of the most strategic and heavily guarded areas of the capital, near the Somali presidential palace.

Godka Jilicow is controlled by Somalia's National Intelligence and Security Agency (NISA) and holds not only al-Shabab members but also other high-profile detainees.

This incident poses a significant blow to NISA and could provoke scrutiny over how militants accessed such a secured zone.

Affiliated with al-Qaeda, al-Shabab has led a brutal insurgency against the Somali government for nearly two decades.

Notably, just hours ahead of the assault, the government had reopened key roads in Mogadishu that had been previously shut down for security concerns, citing improvements in the city's safety.