Gunmen stormed a hotel in the capital of Somalia's semi-autonomous Puntland region on Wednesday, killing four guards.
In a nation awash with weapons, it was not immediately clear who staged the raid in the port city of Bosasso.
An official blamed al-Shabab fighters, but a spokesman for the armed group denied involvement.
"Three al-Shabab fighters stormed the International Village Hotel this morning. Four guards and two of the attackers died in the fighting," Yusuf Mohamed, governor of the Bari region, told Reuters news agency.
He said the attackers had not managed to enter the hotel, which is popular with foreigners.
Sheikh Abdiasis Abu Musab, al-Shabab's military operations spokesman, said: "We are not behind the Bosasso hotel attack. It is propaganda."
Al-Shabab regularly launches attacks in Somalia, but tends to focus on the capital Mogadishu and other regions controlled by the federal government.
Until 2011, the al-Qaeda-linked group controlled most of Somalia, including Mogadishu. Since then it has been pushed out of the capital and slowly forced out of other strongholds by African Union troops and Somali soldiers.
Fighters often stage bomb and gun attacks in the capital and other regions in their quest to overthrow the Western-backed government and impose their own strict interpretation of Islamic law on the nation.
READ MORE: Somalia - US accused of killing 22 troops in air strike
Somalia's politicians are due to elect a president later on Wednesday in Mogadishu.
Fears of attacks have limited the election to the country's legislators, who will vote at a heavily guarded former air force base in the capital. Rounds of voting are expected to narrow down the 22 candidates to a winner.
The Horn of Africa nation is trying to put together its first fully functioning central government in a quarter-century. Years of warlord-led conflict and al-Shabab attacks, along with famine, have left the country of about 12 million people largely shattered.
Source: Reuters news agency