Other prominent Libyans who once traveled abroad to fight in the name of Islam are also moving in the same direction. Abdel Hakim Belhaj led an Islamist insurgency in Libya, fought the Soviets in Afghanistan and later joined the Taliban before the C.I.A. captured him in Malaysia. The leader of the Tripoli Military Council, he has founded a political party modeled after Turkey’s loosely Islamic governing party.

“We are not an Islamist party,” said Anas al-Sharif, a former spokesman for the Islamist insurgency.

There are, however, still signs of division among Darnah’s jihadis. During last year’s rebellion, graffiti proclaimed “No to Al Qaeda.” Now the word “no” is blacked out. A few weeks ago, after Mr. Hasadi spoke at a mosque about the coming elections, militants blew up his car.

“For sure we have extremists,” said Mohamed el-Mesori, 52, who leads the local governing council. “There are people who are not with Hasadi because he speaks about democracy and elections,” he said, adding: “Sufian bin Qumu is not yet convinced of that, but we think he is open. People are trying to show him that this is the only way to convince people of your ideas.”

Surrounded by mountains pocked with deep caves, Darnah has been a natural center of guerrilla resistance since the Ottoman Empire. In the 1980s, some of its young men joined the fight against the Soviets in Afghanistan, then returned in the 1990s to form the core of the Libyan Islamic Fighting Group, which for a brief time threatened Colonel Muammar el-Qaddafi.