MOGADISHU (Reuters) - A suicide bomber blew himself up in front of a mosque in the center of Somalia’s capital Mogadishu on Friday, killing a soldier, police said, in an attack claimed by the militant Islamist group al Shabaab.

Police spokesman Major Mohamed Hussein told Reuters the bomber had wanted to target a commander of Somalia’s prisons department who was praying inside the mosque.

A soldier intercepted the attacker before he entered the mosque and as he tried to push him back, the bomb exploded, killing the bomber and the soldier, Hussein said.

“The suicide bomber had a prison police uniform and an explosive jacket on top,” Hussein said.

Al Shabaab carries out frequent bombings in Mogadishu and other towns aimed at toppling the central government in the Horn of Africa nation and driving out the Africa Union-mandated peace keeping force AMISOM.

Sheikh Abdiasis Abu Musabb, al Shabaab’s military operations spokesman, told Reuters the group was behind the assault and that the attack had caused “deaths and injuries”, without giving a figure. He said the group was targeting a senior prisons official.

Also on Friday, the militants said they had publicly executed two Somali men in Jamame, a small town about 60 km (40 miles) north of the port city of Kismayu in southern Somalia.

The men had been interrogated and found to be spies for Somalia’s semi-autonomous region of Jubbaland, said Sheikh Mohamed Abu Abdalla, designated as “governor” by al Shabaab for the Jubba regions of southern Somalia.

“The two men admitted they were spies. They were shot dead publicly according to (Islamic) Sharia law,” he told Reuters.