Extremists from the Al Qaeda-linked Islamic terrorist group Al-Shabab attacked the presidential palace in Somalia’s capital Tuesday, which led to a shootout that spread from the heavily fortified government complex to a nearby hotel.

All five heavily armed Islamic extremist rebels from the group, which is trying to topple Somalia’s weak United Nations-backed government, were killed by security forces, The Associated Press reported.

Police Capt. Mohamed Hussein said that soldiers shot dead three attackers near the entrance to the presidential residence in Mogadishu, and then killed the last two near the parking lot of the nearby hotel after they took positions by the kitchen area, close to the first gate of the hotel compound.

An ambulance carrying an injured person from an attack by Al-Shabab gunmen on a hotel near the presidential residence arrives to the Shaafi hospital in Mogadishu, Somalia December 10, 2019. (REUTERS/Feisal Omar)​​​​​​​

At least three people were killed in the firefight at the hotel, which lasted about two hours and was marked by sustained gunfire punctuated by grenade blasts, said Ahmed Ali, a Somali police officer.

He said 20 others, including government officials, were rescued from the hotel, frequented by government officials and Mogadishu’s elite.

Al-Shabab later claimed responsibility for the attack, according to an announcement on their Andalus radio station.

The rebel assault was carried out completely by gunmen on foot, security officials said.

New security measures, including multiple checkpoints across Mogadishu, have made it difficult for the rebels to sneak car bombs into the capital city, and have forced the rebels to stage attacks on foot.

CLICK HERE FOR THE FOX NEWS APP 

Al-Shabab extremists in September staged an attack on a U.S. military base in Somalia, which is used to launch drone strikes.

An all-night siege that lasted more than 14 hours in July was waged by Al-Shabab extremist militants at a Somali hotel in the southern port city of Kismayo; it ended with 26 people -- including two Americans -- being killed.

The Associated Press contributed to this report.