The decision means 2018 elections in the state will probably be held in districts far more favorable to Democrats.