The ruling follows a lawsuit filed earlier this month by a coalition of 17 Democratic state attorneys general.