FEW Muslim sites are more serene than the resting place of Ali ibn Abi Talib, the seventh-century caliph who was the first Shia leader, in Najaf, the Shia world’s spiritual capital. Its cupola glitters with gold leaf, its marble floors gleam in the sunlight, and pilgrims throng prayer halls that shine with a million mirrored mosaics. But in their seminaries surrounding the shrine, the ayatollahs and their 13,000 students are engaged in a less-than-holy struggle to block an Iranian takeover bid.

As their financier and weapons supplier, Iran already holds sway over Iraq’s main Shia parties and their allied militias. But control of Najaf would be its greatest prize. Standing between Iran’s supreme leader, Ayatollah Ali Khamenei, and his aspirations for spiritual leadership of the world’s 200m Shias is an ailing 85-year-old, Grand Ayatollah Ali al-Sistani. Mr Sistani has refused to recognise either the legitimacy of Iran’s theocracy or the qualifications of its incumbent, Mr Khamenei, to be Shia Islam’s chief faqih, or jurist. “Sistani is emphatic. He doesn’t want a religious state, he wants a civil state,” says a senior cleric close to him.

Key Iraqi figures have already switched allegiance to Mr Khamenei. They include Nuri al-Maliki, Iraq’s former prime minister and the leader of Dawa, the country’s largest Shia party. The most powerful militia associated with the State of Law coalition, which Mr Maliki heads, is Badr, with some 20,000 men under arms. Badr plasters its barracks with portraits of the Iranian leader. In a country where the militias have more firepower than the army, Iran’s pawns dominate most areas of Iraq that lie outside the control of the Kurds or Islamic State (IS). Mr Sistani has repeatedly sought to roll back their influence. He stymied Mr Maliki’s bid for a third term after the 2014 elections, and has given unqualified backing to attempts by the current prime minister, Haider al-Abadi, to rein in the militias.

Aside from the battle against IS, Mr Sistani has shied away from joining Iran’s other regional adventures, says an aide. The ayatollah has declined the demands of Hizbullah, the Iranian-backed Shia militia that is Lebanon’s most powerful force, for a religious decree endorsing their multiple struggles. He opposes Shia intervention on behalf of the Houthi militia that took up arms against Yemen’s government. And he has doggedly refused to endorse the idea that his supporters should fight Sunni rebels in Syria as well as in Iraq, joining Iran and its friends in buttressing the regime of Bashar al-Assad. Shias who die fighting in Syria “are not martyrs”, a cleric says he heard him saying.

For now, most Iraqis continue to offer Mr Sistani their allegiance. “The marja still holds the keys of Najaf,” says the cleric, using the honorific (which means “source of emulation”) many Shia use for their religious authority. But since he has no apparent successor, real questions surround the future of Najaf’s seminaries when Mr Sistani dies. Two of the strongest contenders both live in Iran, including Mr Maliki’s preference, Mahmoud Hashemi Shahroudi. Though born in Najaf, he is a senior figure in Iran’s theocracy and a staunch supporter of Mr Khamenei. He headed Iran’s judiciary for a decade, and serves on Iran’s powerful Council of Guardians, which vets new laws and parliamentary candidates. A Najaf cleric voiced scepticism about the prospects of a Shahroudi succession: “Najaf is too small for him. He wants to succeed the supreme leader.”

For now, Ayatollah Shahroudi keeps his distance, but his followers are putting the finishing touches to what could be Najaf’s largest seminary. Its turquoise-tiled portico towers over the otherwise modest academies on adjacent streets. Just across the way from Mr Sistani’s rented lodgings, more champions of Iran’s theocracy are preparing to open a museum in the richly restored garret where Ayatollah Ruhollah Khomeini, the father of the Islamic Revolution, lived and lectured for 15 years. “If Sistani dies, we’ll be… subsumed under the leadership of the faqih,” says Saad Salloum, an academic and keen observer of Iraq’s religious affairs.

Beyond Iraq, neighbouring Arab states also show signs of alarm at the prospect of Iran’s move into yet another Arab landmark and Iraq’s steady transformation into an Iranian satellite. Under King Salman, Saudi Arabia is quietly overcoming its own religious qualms and is reaching out to Arab Shias. It invited Mr Abadi to visit earlier this year. Western capitals too look on Mr Sistani as one of the country’s few positive post-2003 constants, and a buttress against the country’s sectarian slide. “Thank God Sistani is here,” says a western diplomat in Baghdad. For how much longer, though, no one knows.

This article has been edited to clarify the relationship between the Badr militia and Mr Maliki.