By Gary Robertson

RICHMOND, Virginia (Reuters) - The Virginia Supreme Court ruled on Friday against Democratic Governor Terry McAuliffe's order restoring voting rights to more than 200,000 felons who completed their sentences, court documents show.

The court in a 4-3 ruling 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.

In its opinion, the Virginia Supreme Court said that none of the state's previous 71 governors had ever issued a clemency order to a class of felons.

"To be sure, no governor of Virginia, until now, has even suggested that such a power exists," the court said. "And the only governors who have seriously considered the question concluded that no such power exists."

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

Clinton chose U.S. Senator Tim Kaine of Virginia as her vice presidential running mate on Friday to help her do battle with Republican nominee Donald Trump in November's election.

John Whitbeck, chairman of the Republican Party of Virginia, hailed the ruling, saying in a statement that McAuliffe's decision amounted to "a blatant effort to stack the deck for Hillary Clinton in November."

Lawyers for leaders in the Republican-controlled Virginia legislature had argued that McAuliffe exceeded his authority by restoring voting rights en masse, rather than on a case-by-case basis.

Virginia is one of four states whose constitutions permanently disenfranchise felons but allow the governor to restore voting rights, according to the Brennan Center for Justice, a non-partisan civil liberties group.

McAuliffe said in a statement after the ruling that the court "has placed Virginia as an outlier in the struggle for civil and human rights."

"It is a disgrace that the Republican leadership of Virginia would file a lawsuit to deny more than 200,000 of their own citizens the right to vote," he said.

McAuliffe said he would sign "nearly 13,000 individual orders to restore the fundamental rights of the citizens who have had their rights restored and registered to vote."

Many of the convicts benefiting from the order are African-Americans or Latinos, two groups that have voted overwhelmingly for Democratic candidates in the past.

President Barack Obama, a Democrat, won Virginia in 2012 by about 150,000 votes and in 2008 by about 235,000 votes.

(Reporting by Gary Robertson in Richmond, Virginia; Additional reporting by Eric Beech in Washington, D.C., and Eric M. Johnson in Seattle; Writing by Eric M. Johnson; Editing by Mohammad Zargham and Leslie Adler)