The latest in a spate of clashes in Galkayo, a city divided between the semi-autonomous regions of Puntland and Galmudug, erupted on Sunday following a dispute over building plans.
Col. Mohamed Aden, a Puntland military officer, said 16 soldiers serving in the region's armed forces had been killed and 30 wounded.
The mayor of southern Galkayo, Hirsi Yusuf Barre, said the toll on the Galmudug side was 13 dead and 20 wounded.
Doctors at hospitals in north and south Galkayo, who asked not to be named for fear of reprisals, put the overall death toll at at least 50.
Both militias offer political support to Somalia's U.N.-backed government, based in the capital Mogadishu. But the clashes between them underscore the tenuous grip it exerts on Somalia's powerful regions.
Civil war has been raging in Somalia for 25 years.