The Supreme Court ruling marked the culmination of a frenzied, monthslong legal battle