Nine Somali soldiers including two generals were killed on Thursday by a blast just outside the capital Mogadishu, militants and an army official said.

Islamist group al-Shabab claimed responsibility, saying it had destroyed a military pickup truck carrying the generals and their seven bodyguards near Dhanaane village just outside Mogadishu on Thursday afternoon.

Abdiasis Abu Musab, al-Shabab's military operation spokesman, identified the slain generals as Omar Aden and Abdi Ali.

"We destroyed their pickup with a roadside bomb near Dhanaane village," he told Reuters.

A military official who identified himself as Capt. Mohamed confirmed to Reuters the two generals and their guards had been killed while others were injured.

Al-Shabab has for years been fighting to topple Somalia's Western-backed central government and install its own rule based on a strict interpretation of sharia law.

The country has been gripped by insecurity and lawlessness since the early 1990s.