His condition had already seriously deteriorated over the last months, aggravated by his nervous condition due to  his inability to solve the problems created by his manipulation of the election results and the refusal of [a large part of] the population to accept this, plus  his loss of religious authority by means of the repeated condemnations of events by senior clerics.
Reportedly the principal aims of Khamenei of the last couple of weeks, if not months, were to ensure  a positive reputation as his legacy and  the physical survival of his family members and their wealth, reportedly now largely in Syria and in Turkey (remember the truck convoy of $8.5 billion in cash and gold that was seized by the Turks?).
Outlook is uncertain but speculation is – considering that he is in coma since more than 24 hours – that he may not come out of his coma and/or that he may die very soon.
Before the summer uprising, the odds-on choice to succeed him was Rafsanjani, the “pragmatist” head of the Assembly of Experts (a.k.a. Shiite College of Cardinals) that’s charged with electing a new supreme leader. But Rafsanjani was sympathetic to the protesters in June, so presumably the Revolutionary Guard — the real source of power in Iran — won’t let him come to the throne. So, then … who? One possibility is the Ayatollah Mesbah Yazdi, Ahmadinejad’s own personal “spiritual advisor” and a jihadist so hardcore that his top disciples have already come out publicly in favor of Iranian nuclear weapons. If he’s the pick, it’s panic time. Another possibility is that the Guard will simply finish the process started this summer and stage a full-blown military coup, installing Ahmadinejad or Jafari as dictator and taking things from there. The tricky part, obviously, would be the risk of alienating religious Iranians by doing away with clerical rule, which is why the third possibility is the likeliest — namely, finding a puppet from among the clerical ranks who can be sold to the west as a “pragmatist” or “reformist” while letting the Guard control things behind the scenes. That’s basically the scam they’re running now, although an infusion of fresh blood at the top would give them new possibilities for jerking the U.S. around with promises that the next supreme leader is someone “we can do business with.”
The odds are low but the stakes are high, so here’s your thread to speculate. Fire away.