The Shariah court that carried out the sentences is run by the powerful insurgent group al-Shabab, which is trying to topple Somalia's U.N.-backed government and install a strict form of Islam.
"The men were bleeding and crying when the man cut their hands and feet off with a long knife," said one witness, Liban Ali. Journalists were not allowed to cover the sentencing. The four were convicted earlier this week in the capital, Mogadishu.
The U.S. considers al-Shabab a terrorist group with links to al-Qaida, which al-Shabab denies. The group, which controls much of Somalia, is joined by hundreds of foreign fighters.
Somalis traditionally observe Sufi Islam, a relatively moderate form of worship. But in recent years, insurgents have begun to follow austere Wahabi Islam — rooted in Saudi Arabia and practiced by Osama bin Laden and the Taliban.
Somalia has not had an effective government since 1991 when the overthrow of a dictatorship plunged the country into chaos. A surge in violence in recent weeks, which diplomats said is a major push by the insurgents to force the government out of its Mogadishu strongholds, has killed about 225 people.
Last week, the national security minister and Mogadishu's police chief were among those killed.
The country's lawlessness has spread security fears round the region and raised concerns that al-Qaida is trying to gain a foothold in the Horn of Africa.
Somali lawmakers pleaded this weekend for immediate international military intervention from countries including Kenya, Ethiopia and Djibouti to help quash the insurgency. But there was no indication reinforcements would be forthcoming.
Some 159,000 people have fled their homes since May 7, according to the U.N. refugee agency. The United Nations says an estimated 3.2 million Somalis — almost half the country's population — need food and other humanitarian aid.
Two years ago, Ethiopia deployed troops to support Somalia's fragile, Western-backed government, but they were widely unpopular and finally withdrawn in January.