A roadside bomb went off just outside the central Somalia town of Dhusamareeb on Sunday, killing 12 agents working for the National Intelligence and Security Agency, police said.
Those killed included Abdirashid Abdunur, the head of the intelligence agency in Dhusamareeb, police officer Mohamed Ahmed said.
The al-Qaeda-linked armed group, al-Shabab, claimed responsibility for the attack.
Political leaders have been meeting in Dhusamareeb, a town about 510 kilometres (317 miles) north of the capital Mogadishu, to try to resolve a dispute over how to hold an election due on Monday.
A deal on how to choose a new president on Monday has been elusive so far, threatening to unleash more political turmoil.
Somalia had initially aimed to hold its first direct election in more than 30 years but delays in preparations, and the government’s inability to rein in daily attacks by al-Shabab, meant switching to an indirect vote, with elders picking legislators who would choose a president.
However, regional authorities in at least two of Somalia’s five federal states, Puntland and Jubbaland, oppose holding the election for now.