The inside story of how the CEO of the hottest tech company was ousted and, just as quickly, resurrected.