Somali President Sharif Sheikh Ahmed has escaped unscathed from an ambush by al-Shabab fighters during a visit to the al-Qaeda-linked group's former stronghold of Afgoye.
Ahmed was making a rare trip out of Mogadishu on Tuesday when the convoy was attacked by gunmen in the Afgoye corridor, a key road about 30km north of the capital.
Two Somali soldiers were wounded in the attack but Ahmed was able to continue his trip, a Somali security official said.
"Desperate terrorist militants tried to disturb the visit of the president [to] the Afgoye corridor by ambushing his convoy, but security forces repulsed them," said Mohamed Moalim. "The president is well and continued his trip smoothly."
The armoured convoy was guarded by African Union troops and Somali government soldiers, who seized Afgoye last week after a four-day battle.
A pro-Shabab website said its fighters had carried out the attack against "the head of the enemy" and that Sharif had been saved after he was "surrounded by African Union troops and white gunmen for his safety".
The loss of Afgoye, which controls key roads north of the capital, was another major blow for al-Shabab which has been on the back foot for several months despite launching a wave of guerrilla attacks.
Although it controls large parts of southern Somalia, regional armies and government troops have been regaining territory, with AU forces in Mogadishu, Ethiopian soldiers in the south and west, and Kenyan troops with the AU in the south.
In the port town of Kismayo, the group's last major bastion, al-Shabab said its fighters had exchanged gunfire with warships.
"The mujahideen fighters opened fire and repulsed two military ships that approached the coast of Kismayo, they were coming close to the coast when they were attacked," said Sheikh Hassan Yaqub, an al-Shabab official in Kismayo.
"They have sped away from the coastal areas after the shooting and they are not there anymore," Yaqub added.
"Those war vessels also returned fire," he said, adding that a boy had been wounded in a neighbourhood close to the shore, but that no other casualties had been reported.
Several foreign navies operate anti-piracy patrols off the coast of the Horn of Africa nation.
Kenyan army spokesman Colonel Cyrus Oguna said there were "naval patrols close to Kismayo", but could not confirm if Kenyan vessels were those involved in the clashes.
Nine warships in a European Union naval force are currently deployed off Somalia by France, Germany, Spain, Portugal, Italy and the Netherlands. But the force is deployed to tackle piracy rather than to fight against al-Shabab.