Neil MacFarquhar The New York Times KAIROUAN, Tunisia — On the Friday after Tunisia's president fell, Mohamed Al-Khelif mounted the pulpit of this city's historic Grand Mosque to deliver a full-throttle attack on the country's corrupt culture, to condemn its close ties with the West and to demand that a new constitution implement Shariah. “They've slaughtered Islam!” thundered Dr. Khelif, whom the ousted government had barred from preaching for 20 years. “Whoever fights Islam and implements Western plans becomes in the eyes of Western politicians a blessed leader and a reformer, even if he was the most criminal leader with the dirtiest hands.” Mosques across Tunisia blazed with similar sermons that day and, indeed, every Friday since, in what has become the battle of the pulpit, a heated competition to define Tunisia's religious and political identity. Revolution freed the country's estimated 5,000 officially sanctioned mosques from the rigid controls of the previous government, which appointed every prayer leader and issued lists of acceptable topics for their Friday sermons. That system pushed a moderate, apolitical model of Islam. When the system collapsed last year, ultraconservative Salafis seized control of up to 500 mosques by government estimates. The government, a proponent of a more temperate political Islam, says it has since wrested back control of all but 70 of the mosques, but acknowledges it has not yet routed the extremists nor thwarted their agenda. “Before, the state suffocated religion — they controlled the imams, the sermons, the mosques,” said Sheik Tai'eb Al-Ghozzi, the Friday prayer khateeb at the Grand Mosque here. “Now everything is out of control — the situation is better but needs control.” The battle for Tunisia's mosques is one front in a broader struggle, as pockets of extremism take hold across the region. Freshly minted Islamic governments largely triumphed over their often fractious, secular rivals in post-revolutionary elections. But those new governments are locked in fierce, sometimes violent, competition with the more hardline wing of the political movements over how much of the faith can mix with democracy, over the very building blocks of religious identity. That competition is especially significant in Tunisia, once the most secular of the Arab nations, with a large educated middle class and close ties to Europe. The Arab Spring began in Tunisia, and its ability to reconcile faith and governance may well serve as a barometer for the region. Some analysts link the assertive Tunisian Salafi movement to what they consider a worrying spread of violent extremism across North Africa — including an affiliate of Al-Qaeda seizing control of northern Mali; a murderous attack on the American diplomatic mission in Benghazi, Libya; and a mob looting an American school and parts of the United States Embassy in Tunis.