Justice Anthony M. Kennedy announced on Wednesday that he would retire, setting the stage for a furious fight over the future direction of the Supreme Court.