Closely watched race for a seat on the state’s highest court served as a proxy battle over the nation’s political future