What's that saying? You don't know what you've got 'til it's gone? Well, after eight long years of Mahmoud Ahmadinejad as president of Iran, I'm willing to bet that even those of us who loathe the man are going to end up missing him -- not just because of the comedy he provided with his bellicose rhetoric and his inane populism, but because he may have been the last, best hope of stripping the clerical regime of its "God-given" right to rule Iran. Back in 2011, I argued that those who oppose the clerical regime in Iran and who yearn for a more secular nation that looks for inspiration in the glories of its Persian past instead of its Islamist present may have an unexpected champion in their corner: Mahmoud Ahmadinejad. I was not suggesting that Ahmadinejad is some sort of democracy icon or that he is even a good guy, let alone a competent president -- though he is far more politically sophisticated than his critics generally assume. It is a Western fallacy that "more secular" necessarily means "more free." But the fact remains that no president in the history of the Islamic Republic has so openly challenged the ruling religious hierarchy, and so brazenly tried to channel the government's decision-making powers away from the unelected clerical bodies that hold sway in Iran. Under Ahmadinejad, the presidency has become a legitimate base of power in a way it never had been before. That may explain why Supreme Leader Ayatollah Ali Khamenei has lately been threatening to get rid of the office altogether. At the time, I was skewered for the article by many in the Iranian-American community. My critics did not object to the content, they simply hated that I said something remotely positive about a man who had become the poster child for everything loathsome about the Iranian regime. I was equally taken to task by some American journalists, who seem incapable of viewing Ahmadinejad through any other lens save his absurd and odious views on Israel. Today, Ahmadinejad's unprecedented challenge to the unchecked powers of the supreme leader is something even those who can't stand the man recognize and grudgingly admire. And now, as Ahmadinejad is about to be replaced by one of a claque of Ayatollah Khamenei's fawning admirers, we may start to think a little more kindly of these last few years. The mullahs' conflict with Ahmadinejad goes to the very heart of what constitutes political legitimacy in the Islamic Republic. In Iran's byzantine government, the elected president is supposed to represent the sovereignty of the people while the unelected supreme leader represents the sovereignty of God. In practice, however, nearly all levers of political power rest in the hands of the supreme leader, leaving the president with very little control over policy decisions. That is just how the founder of the Islamic Republic, Ayatollah Ruhollah Khomeini, wanted it. Khomeini's religio-political concept of velayat-e faqih, or "guardianship of the jurist" argued that in the absence of the Muslim messiah (known as the Mahdi), the powers of government should rest with the messiah's representatives on Earth -- that is, the ayatollahs. After creating the position of supreme leader, Khomeini named himself to the office and began accumulating absolute religious, economic, and political authority, paving the way for complete clerical dominance. This clerical dominance extended even into the elected branches of government. The clergy made up more than half of the representatives in Iran's first two parliaments, though that number has gradually declined to less than a quarter today. With the exception of the Islamic Republic's first and second presidents -- who served a total of less than two years in office before being impeached and assassinated, respectively -- every president elected in post-revolutionary Iran before 2005 had been a cleric. Ahmadinejad broke that clerical precedent when he trounced his opponent, Ali Akbar Rafsanjani, by painting him as a wealthy, corrupt, out-of-touch mullah with no appreciation for the common man's concerns. In contrast to the fantastically wealthy Rafsanjani, whose speeches were peppered with Arabic words and Quranic recitations, Ahmadinejad dressed simply, spoke colloquial Persian, and clothed himself in a provincial religiosity deliberately stripped of clerical learning. The strategy was so successful that Ahmadinejad won 62 percent of the vote in the run-off election against Rafsanjani, who mustered a mere 36 percent. Nor did Ahmadinejad back away from his controversial public persona after taking office -- long before his sham reelection in 2009, he had begun distancing himself from the clerical elite and consolidating power in the presidency. Ironically, it was after the so-called Green Movement uprising was violently suppressed and his reelection staunchly supported by Khamenei that Ahmadinejad's anti-clerical agenda became more pronounced. In his second term, Ahmadinejad steadily chipped away at the clergy's religious, economic, and political control. First, he started questioning the mullahs' self-proclaimed status as the arbiters of Islamic morality -- and especially its obsession with proper Islamic dress. He condemned the actions of the country's dreaded morality police, saying, "it is an insult to ask a man and woman walking on the street about their relation to each other." Ahmadinejad's media advisor, Ali Akbar Javanfekr, was even arrested for printing articles criticizing the law forcing women to wear veils. The president then began repeatedly criticizing the clergy for their enormous wealth, which stood in stark contrast to most Iranians' economic suffering under international sanctions. In a surprise move, Ahmadinejad curtailed the amount of money that the government pays to religious institutions, which have ballooned over the past three decades into a source of tremendous personal enrichment for many in the clerical elite. Ahmadinejad also took a number of bold steps to wrest political power away from the mullahs. He ceased attending meetings of the Expediency Council, one of Iran's many Orwellian committees whose purpose is to protect the political interests of the clergy. When Iran's oil minister stepped down, Ahmadinejad took over the ministry himself until a permanent replacement could be found, establishing an extremely significant presidential precedent in the process. Even in those cases when his attempts to consolidate power were foiled by Khamenei and his allies, Ahmadinejad showed a brazen unwillingness to bend to the supreme leader's whims. When Khamenei overruled the dismissal of his intelligence chief, Heider Moslehi, Ahmadinejad went on a week-long "strike," refusing to attend cabinet meetings in protest. When Khamenei rejected the appointment of his close ally, Esfandiar Rahim Mashaei, as first vice president, Ahmadinejad made him chief of staff instead -- an arguably more influential position that did not require Khamenei's approval. When Khamenei balked at Ahmadinejad's habit of appointing "special envoys" -- an attempt to sidestep the Foreign Ministry, which is under Khamenei's control -- Ahmadinejad simply changed the envoys into "advisors" and carried on. But Ahmadinejad's challenge to the clerical regime goes beyond any single skirmish with the supreme leader. Perhaps more important is his very public questioning of the foundation of the Islamic Republic's political and religious authority. "Administering the country should not be left to the [supreme] leader, the religious scholars, and other [clerics]," the president said in 2011. Mashaei went further, flatly arguing that an Islamic government is not capable of running a vast and populous country like Iran. These are astounding statements for the president and his closest advisor to make. Indeed, they are downright seditious -- it would be like the president of the United States questioning the viability of constitutional democracy. No one in the Iranian government -- not even the most liberal reformists in parliament -- has ever dared to overtly challenge the divine right of the supreme leader to run the country. But for Ahmadinejad, direct assaults on the velayat-e faqih have become a standard part of his rhetoric. Consider, for example, Ahmadinejad's much-maligned claims of being in direct communication with the Mahdi. Such statements are not the mad ravings of a religious fanatic -- they are a public repudiation of the entire system upon which the Islamic Republic was built. After all, if a layperson like Ahmadinejad can directly consult with the Mahdi, then what use are the ayatollahs? And if the clerics are not the only ones with a direct line to the Mahdi, why have they been given political powers over the Mahdi's government? As Mashaei put it, "Running a country is like a horse race, but the problem is that [the clerics] are not horse racers." Khamenei immediately grasped the challenge that Ahmadinejad and Mashaei's statements represented for religious rule, issuing a fatwa announcing that he and only he represents the Mahdi. But despite the backlash from the clergy, Ahmadinejad has continued to use the president's bully pulpit to push for a new ethos of "Persian nationalism" over Iran's Islamic identity. He has called for an "Iranian Islam" that contrasts with the theocratic ideology pushed by the clerical regime -- what some Iranians refer to derisively as "Arabism." Ahmadinejad has also broken a taboo among Iranian politicians by heaping praise on Cyrus the Great, the first and greatest king of the ancient Persian Empire. This nostalgia for Iran's pre-Islamic past has led to strict warnings from Khamenei's allies, with one conservative parliamentarian saying that the president "should be aware that he is obligated to promote Islam and not ancient Iran, and if he fails to fulfill his obligation, he will lose the support and trust of the Muslim nation of Iran." However, Ahmadinejad's Persian nationalism has proven enormously popular in Iran. It has even led to a new political movement in the country, one which the clerical regime's most fanatical supporters decry as a "deviant movement" and "a third pillar of sedition." Ahmadinejad, for his part, has dismissed his critics as the kind of people who go "running to Qom [the religious capital of Iran] for every instruction." With this description, Ahmadinejad could be speaking of any of Iran's presidential frontrunners. After all, the one thing that the top contenders to replace him have in common is their comical obeisance to the supreme leader. Iran's nuclear negotiator Saeed Jalili recently argued that "those with the slightest disagreement with the supreme leader have no place in our discourse" and that "all our attention should be devoted to listening to what our leader wants." Such professions of mindless obedience seem to be the only way to secure the presidency in the coming election. Ali Akbar Velayati, another presidential frontrunner, has said that his greatest strength as president would be his willingness to unquestioningly obey whatever the supreme leader tells him to do: "I see this as a strong point.... I believe that having a person who has the last word and makes the final decision is in the country's political interest. Mohammad Bagher Qalibaf, the brutish mayor of Tehran, has boasted about standing up for the supreme leader's right to rule by personally bashing in the heads of student protesters who question it. "When it is necessary to come to the street and hit [the protesters] with batons I am there with a baton and I am proud of that," he said. In fact, none of the current presidential candidates, not even the moderate Hassan Rouhani, who, despite his brash criticisms of the "excesses" of the clerical regime is himself a mullah, seem too eager to carry Ahmadinejad's mantle of anti-clericalism into their administrations. Barring some major surprise, which Khamenei has done everything in his power to prevent, one of the three sycophants listed above will likely be the next president of Iran. That will also mark the end to Ahmadinejad's unprecedented challenge to the guiding philosophy of the Islamic Republic. As clerical control over the Iranian government becomes more severe, those who blame the mullahs for everything wrong in Iran may one day come to miss the little man with the unkempt beard and rumpled jacket who dared defy the Mahdi's representative on Earth.