If Ayatullah Ali Khamenei's improbable haste in declaring Mahmoud Ahmadinejad the winner of Iran's June 12 presidential election was motivated by a desire to smooth his ally's path to a second term of office, it had quite the opposite effect. Eight weeks later, as Ahmadinejad was sworn in by Iran's parliament on Aug. 5, the Islamic Republic remains in the grip of an unprecedented political crisis over the legitimacy of both men  a crisis that shows no sign of abating, either on the streets or inside the corridors of power. (Read "Khamenei: The Power Behind the President.")

That much was clear in reports from Iran on Aug. 4 that, as part of preparations for the swearing-in ceremony, the Revolutionary Guard Corps had instructed hospitals near parliament to be ready for casualties from the anticipated protests. And the Aug. 3 ceremony in which Khamenei formally acknowledged Ahmadinejad's election victory was marked both by a noticeable awkwardness between the two men, and the noteworthy absence of some key figures in the regime, that may have reflected the bruising power struggle under way among the heavyweights of the Islamic revolution. For the first time in 20 years, the event was not broadcast live, a move many suspected was made to prevent the public from witnessing a few political black eyes or metaphorical missing teeth. (See pictures of the enduring influence of Ayatullah Khomeini.)

Even if their numbers are dramatically reduced from the hundreds of thousands that first marched to cry fraud in the days immediately after June 12, the very fact that protesters are still taking to the streets  as hundreds did on Aug. 3, while Khamenei was formally confirming Ahmadinejad  is, in itself, remarkable. After all, to protest now is to risk a cracked head, or far worse; for all the mixed signals from Iran's top echelons of power, the security forces have exhibited few qualms about doing whatever it takes to quiet the streets, including the imprisoning of an estimated 2,000 opposition supporters. And all those taking to the streets are well aware that a number of detainees have died in the regime's custody. The taped "confessions" presented Aug. 2 in the hastily convened trial of 100 detainees, ranging from notable senior political figures to demonstrators arrested on the streets, were widely viewed as forced, which sounded a further warning of what those challenging the regime on the streets might expect if they're arrested. (See pictures of Iran's presidential election and its turbulent aftermath.)

Equally remarkable is the fact that many of the protests that continue in defiance of Khamenei's dire warnings weeks ago that those who continue to demonstrate would be treated as enemies of the Islamic Republic are still joined by such notable establishment figures as former President Mohammed Khatami, reformist candidate Mehdi Karroubi and Mir-Hossein Mousavi, the leading opposition candidate. Khamenei's red lines have been ignored by the opposition, and his own legitimacy has been questioned as never before, whether by street protesters breaking a taboo by shouting slogans against him, or by key regime figures like former President Ali Akbar Hashemi Rafsanjani openly rebuking his partisan interventions as an abuse of his office. Even Ahmadinejad himself has lately taken steps that flagrantly challenge Khamenei's authority.

The failure of the regime to quiet the streets and to close ranks behind Khamenei in his endorsement of a second Ahmadinejad term is without precedent in the Islamic Republic's 30-year history. As leading U.S.-based Iran scholar Farideh Farhi told the Council on Foreign Relations, Khamenei and Ahmadinejad had assumed that "if they use a sufficient amount of violence, they can put an end to the popular anger that has been generated. [Instead], they continue to be surprised by the resistance that is being shown  not only by major players in Iranian politics, but the people of Iran as well. This dissatisfaction has been growing since the election." (Watch TIME's video "Iranian Rockers Unite for Freedom.")

Where the battle lines within the regime initially appeared to be relatively clear-cut  Ahmadinejad, Khamenei and the Revolutionary Guards on one side, facing off against a coalition of conservative pragmatists and reformists on the other, with each side claiming some support from within the clergy  the picture has grown murkier over the eight weeks of crisis. A number of figures in the conservative clerical and political establishment have begun to question the authorities' handling of the election's aftermath, particularly the crackdown on dissent. And there are clear signs from within the conservative clergy that some feared Ahmadinejad and the security establishment were usurping some of the traditional prerogatives of the clerical ruling class. (See the top 10 Ahmadinejad-isms.)

Tension between the President-elect and his chief patron flared in public last week when Khamenei ordered Ahmadinejad to fire his chosen deputy, Esfandiar Rahim Mashaei. Ahmadinejad not only publicly dragged his feet for almost a week in implementing the order, he made his contempt for the Ayatullah's edict plain by immediately reappointing Mashaei as his chief of staff. The President also sacked members of his Cabinet who had insisted that Khamenei's demand be heeded, including the powerful conservative Intelligence Minister. Following that clash of wills, a Tehran newspaper known to express Khamenei's views called the President a man of "little knowledge." And it's not clear whether Ahmadinejad had the backing of the Revolutionary Guards in his defiance of Khamenei, because the corps' main newspaper criticized the President and backed the Supreme Leader on the issue. Khamenei last week also sought to express his authority  and, perhaps, seek to heal the rift within the regime  by ordering the closure of one of the makeshift detention centers where people rounded up during the crisis have been held. (See pictures of Mahmoud Ahmadinejad.)

The Aug. 5 swearing-in will have surely reminded Ahmadinejad of the challenge he faces in the Majlis, Iran's elected parliament. The ceremony was addressed by Speaker Ali Larijani, a longstanding conservative rival of Ahmadinejad, who has tried to position himself between the opposition and the government  at times being fiercely critical of the crackdown and demanding a public inquiry, at others distancing himself from the opposition movement and railing against foreign interference. The President requires approval of his Cabinet picks from parliament, and also needs the legislature's cooperation in passing new laws. And he is far from guaranteed the support of a majority. Some Iran watchers saw the Aug. 3 comment by Ahmadinejad that he would "invite all for active participation and planning" as a signal that he may seek to pick a more inclusive Cabinet in order to defuse tensions. (Watch TIME's video "An Iranian Protest March in Paris.")

For now, however, both the President and his backers and foes are sailing in uncharted waters. The rupture in the regime  and in its constitutional contract with the Iranian people, which allows them to democratically choose their President, even if from a limited palate of options  that occurred after June 12 has not been healed. In his second term, Ahmadinejad will have to navigate both the ongoing socioeconomic crisis in Iran, and the international battle of wills over its nuclear program, from a position of diminished political authority and legitimacy. And his domestic political opponents are showing no sign of easing the pressure.