"Al-Shabab told us that they were beheaded for reasons they described as being Christian followers and spies," Aden, a relative of another of victims told the Reuters news agency.
Muktar Abdullahi, whose brother was one of the murdered men, told the AFP news agency: "Nobody has clearly explained to us why they were killed, but some Shabab members say they were aiding the Somali government."
Torture and execution
The transitional government is led by Sharif Ahmed, the president, who is a former leader of the opposition Islamic Courts Union, which included al-Shabab among its members and seized power in much of the country in late 2006.
However, after Ahmed became president as part of a UN-brokered peace deal, his former allies called him a "traitor" and vowed to topple his government.
Since May, the violence has increased as al-Shabab, along with the allied Hizbul Islam movement, has fought back against a government offensive aimed at pushing them out of the capital, Mogadishu.
Benedicte Goderiaux, a Somalia researcher for Amnesty International, said that Wednesday's executions reflected a broader pattern of torture and extrajudicial executions by the armed opposition.
"It's definitely linked to al-Shabab wanting to show or portray themselves as restoring law and order in the region they control," Goderiaux said.
"It's also linked to them wanting to terrorise the population under their control under the guise of applying sharia law."
In Kismayo, a southern port city under al-Shabab control, a 13-year-old girl was stoned to death last October after being accused of adultery and a man also had a hand amputated after being accused of theft.
Last month, four men each had a hand and foot amputated after being accused of theft in Mogadishu and another man accused of rape and murder was stoned to death in a town south of the capital.
The government says that al-Shabab, which the United States accuses of having close links with al-Qaeda, has been bolstered by hundreds of foreign fighters.
"The current war is a foreign war led and supported by outside forces. The money and ideologies are foreign-based. Somalis all support the government," Mohamed Abdullahi Omaar, the Somali foreign minister, told reporters in the Ethiopian capital, Addis Ababa.
"This is not a war between Somali clans. It is a war against foreign forces who come into the country to overthrow the government that has been elected constitutionally by the Somali people and supported by the international community."
Al-Shabab and Hizbul Islam say they are nationalists seeking to rid Somalia of a Western-imposed government which has no popular support and the foreign troops, in the shape of 4,300 African Union peacekeeping soldiers, that back it.
Somalia has been without an effective government since 1991 when the overthrow of the president plunged the country into chaos.