The chief justice faced down the president, forged unlikely coalitions and achieved long-sought goals.