DUSA MARREB, Somalia  From men of peace, the Sufi clerics suddenly became men of war.

Their shrines were being destroyed. Their imams were being murdered. Their tolerant beliefs were under withering attack.

So the moderate Sufi scholars recently did what so many other men have chosen to do in anarchic Somalia: they picked up guns and entered the killing business, in this case to fight back against the Shabab, one of the most fearsome extremist Muslim groups in Africa.

“Clan wars, political wars, we were always careful to stay out of those,” said Sheik Omar Mohamed Farah, a Sufi leader. “But this time, it was religious.”

Image Sufis are part of a moderate Islamist movement that Western nations are counting on to repel Somalias increasingly powerful Islamist extremists. Credit... Michael Kamber for The New York Times

In the past few months, a new axis of conflict has opened up in Somalia, an essentially governmentless nation ripped apart by rival clans since 1991. Now, in a definitive shift, fighters from different clans are forming alliances and battling one another along religious lines, with deeply devout men on both sides charging into firefights with checkered head scarves, assault rifles and dusty Korans.