The court said McAuliffe overstepped his clemency powers under the state constitution by issuing a sweeping order in April restoring rights to all ex-offenders who are no longer incarcerated or on probation or parole.

If the court had upheld McAuliffe's executive order, it could have helped to tip Virginia, a swing state where the vote is traditionally close in presidential elections, in favor of presumptive Democratic presidential nominee Hillary Clinton.

John Whitbeck, chairman of the Republican Party of Virginia, hailed the ruling as a clear message that "executive power has limits, and no one in Virginia is above the law.

"Terry McAuliffe's decision to break with centuries of precedent in a blatant effort to stack the deck for Hillary Clinton in November was nothing but a naked power grab," Whitbeck said in a statement.