Somalia's armed group al-Shabab has killed two of its own top commanders, one with a US bounty on his head, fighters belonging to the al-Qaeda-affiliated outfit said.

A third commander, Sheikh Hassan Dahir Aweys, was said to be arrested while fleeing the in-fighting and flown to the capital, Mogadishu, on Saturday.

Aweys, who is on the UN's terrorism sanctions list, has apparently agreed to talks with the internationally-backed government.

"We have informed their widows of their deaths, as they must now wear the clothes of mourning," al-Shabab spokesman Abdulaziz Abu Musab told AFP news agency.

The pair killed are two co-founders of the al-Qaeda-linked group, including US-wanted Ibrahim Haji Jama Mead, better known by his nickname "Al-Afghani" (the Afghan) due to his training and fighting there.

Washington offered a $5m bounty for Afghani, who opposed the command of top al-Shabab leader Ahmed Abdi Godane.

Godane, who the US have offered $7m for, earlier this month ordered the arrest of Afghani and at least a dozen other leaders, according to security sources.

Shabab gunmen also killed Abul Hamid Hashi Olhayi, named as another senior commander and co-founder of the group.

The deaths show the splits in the long-running fighting to topple the internationally-backed government, but also signal Godane's efforts to sweep away opposition to his command and cement his leadership.

Family members - including Afghani's sister - said they were arrested and then executed, but the Shabab said they were killed during a gun battle.

Commander arrested

Aweys, one of Al-Shabab's most prominent commanders, has agreed to hold talks with the federal government about his fate, Somali officials said.

Aweys was brought to the city of Adado after his arrest in central Somalia. His capture is a boost to Mogadishu in its battle against armed fighters.

"If he renounces violence, then we can start the discussion about the options available," government spokesman Abdirahman Omar Osman told Reuters news agency, without describing the options.

Speaking before boarding the plane at Adado, the spokesman for the Himan and Heeb regional administration, Mohamed Omar Hagafey, said Aweys had agreed to meet top government officials "after much discussion" that had lasted several days.

Al-Shabab is fractured into multiple rival factions, some based along clan lines and others ideological.

Some are more attracted by a nationalist agenda to oust foreign forces from Somalia, while others - including Godane - had more international ambitions.

However, despite its divisions, analysts say it remains a dangerous and powerful force.