The fighters reportedly launched their attack on Thursday after a bombing near the Amalow Hotel.
Colonel Ahmed Ali, a senior member of the government forces, said that al-Shabab fighters detonated explosives at the entrance before exchanging fire with Somali and African Union (AU) troops at the hotel.
Colonel Ali Aden, a spokesman for the African Union force, confirmed that two AU soldiers of Djiboutian origin were killed in the attack..
Al-Shabab group claimed responsibility for the attack in an announcement on its radio station.
“There was an exchange of fire at the checkpoint, during that exchange the two Djiboutians were killed… the attackers were not able to enter the compound,” said Elio Yao, a spokesman for the UN-backed AU mission in Somalia.
It is the second such attack against the hotel since March, when a bomber and gunmen attacked Amalow Hotel, killing at least five people.
In early March, African Union and Somali troops managed to seize Buulobarde town from the fighters, and al-Shabab has since stepped up attacks against the troops in the town.
Al-Shabab was pushed out of the capital Mogadishu by AU troops in 2011. However, the group still holds several smaller towns and areas in the center and south of the country.
Somalia has been the scene of clashes between government forces and al-Shabab fighters since 1991.
The country did not have an effective central government until September 2012, when lawmakers elected Hassan Sheikh Mohamud as the new president.