MOGADISHU, Somalia - Five heavily armed Islamic extremist rebels attacked the presidential palace in Somalia’s capital Tuesday before all were killed by security forces in a shootout that spread from the heavily fortified government complex to a nearby hotel, police said.

At least three people were killed in the firefight at the SYL 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, have been rescued from the hotel.

Security forces and guards fought off the attackers, denying them access to the hotel, frequented by government officials and Mogadishu’s elite, he said.

Police Capt. Mohamed Hussein said that soldiers shot dead three attackers near the entrance to the presidential residence 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.

Somalia’s extremist rebels, al-Shabab, have claimed responsibility for the attack, according to an announcement on their Andalus radio station.

The attack appears to be a new tactical shift by the rebels. Previously they have used car bombs at heavily fortified targets to blow openings for gunmen to enter on foot. This 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.