A file photo of an armed member of the militant group al-Shabaab attending a rally in support of the merger of the Somali militant group al-Shabab with al-Qaida.

The al Shabaab group linked to al Qaeda plans to target Somali President Mohamed Abdullahi Mohamed and Prime Minister Mohamed Hussein Roble, the country's intelligence agency warned on Tuesday.

Violence by the group, which aims to topple the central government and impose its own severe version of Islamic law, has been an impediment to parliamentary elections taking place since November.

"We informed the key government officials of a plot in which al Shabaab mafia wants to target the president and prime minister," the National Intelligence and Security Agency said on Twitter. "Mohamed Mahir, a senior al Shabaab member, is conducting the plot."

The agency gave no further details. Spokespeople at the offices of President Mohamed and Prime Minister Roble were not immediately available to comment.

Al Shabaab's spokespeople were not immediately available to comment.

The group frequently attacks civilians and government officials and installations. In February, it attacked election delegates in the capital, Mogadishu. The delegates were unharmed but six bystanders were killed.

Late last month, al Shabaab killed 48 people in Beledweyne, around 300 km (185 miles) north of Mogadishu, including traders, clerics, officials and civilians.

Among those killed was Amina Mohamed, a vocal critic of the government, on the eve of her expected re-election.