Allies say Virginia Del. Robert B. Bell (R-Albemarle), second from left, played a leading role in the challenge to an order by Gov. Terry McAuliffe (D) to restore voting rights to nearly 200,000 felons. (Steve Helber/AP)

Republicans said Gov. Terry McAuliffe was trying to help Hillary Clinton, a friend and fellow Democrat, win the crucial swing state of Virginia when he issued a sweeping order to restore voting rights to nearly 200,000 felons.

Now that the state Supreme Court has declared that order unconstitutional, some Republicans think the restoration-of-rights episode could shape yet another political contest: the 2017 race for Virginia attorney general.

Allies of Del. Robert B. Bell (R-Albemarle) say he played a leading, behind-the-scenes role in the legal challenge to McAuliffe and a related public-relations campaign that exposed a series of flaws related to the order.

They think that will help him defeat a Republican rival whose law firm expressed doubts about the case, and beat Attorney General Mark Herring (D) in the general election. Herring’s office represented McAuliffe in the lawsuit brought on behalf of House Speaker William J. Howell (R-Stafford) and a handful of other plaintiffs.

“The case is styled Howell v. McAuliffe, but in reality, this is Rob Bell versus Mark Herring,” said Del. C. Todd Gilbert (R-Shenandoah). “And I can tell you this: No one is more responsible for the outcome than Rob is.”

Herring’s spokesman, Michael Kelly, questioned whether the Republicans’ legal win will translate into a political victory. Democrats have cast McAuliffe’s order as an effort to advance civil rights because state law disenfranchising felons falls disproportionately on African Americans.

“It says a lot that Rob Bell plans to run as a proud architect of voter disenfranchisement,” Kelly said. “The Virginia electorate is getting more diverse every day, and I don’t think they’ll be particularly enamored with the man who says he helped kick 13,000 Virginians off the rolls.”

Kelly was referring to the number of felons who had registered to vote after McAuliffe signed his order in April. In its ruling Friday, the court directed those registrations canceled.

On Monday, McAuliffe said he would individually sign restoration orders for those 13,000 by the end of the week and sign orders for all 200,000 in the next two weeks.

Virginia is one of just a handful of states that ban all felons from voting and require individual exemptions for ex-offenders to vote, according to the Brennan Center for Justice.

With great fanfare in April, McAuliffe restored voting and other civil rights to felons who had completed their terms of incarceration or supervised release. He said the order would help offenders fully rejoin society.

Previous Virginia governors had restored the rights of felons, but on a case-by-case basis. McAuliffe was the first to do so en masse — something the state Supreme Court found unconstitutional.

Republicans were enraged that the order was not limited to nonviolent felons. While the administration said 80 percent of those covered were nonviolent, that still meant 40,000 murders, rapists and other violent criminals had regained the right to vote, sit on juries and apply to have their gun rights restored.

Bell said he was at an annual political confab known as the Shad Planking, in the piney woods an hour west of Virginia Beach, when a reporter alerted him to the governor’s order. From a folding chair behind a tent there, he starting working the phones.

“I called the speaker and other members of the caucus and they said, ‘Let’s get to work,’ ” said Bell, a former Orange County prosecutor, chairman of the House’s criminal law subcommittee and co-chairman of the state crime commission.

Bell said he reached out to a half-dozen law firms before finding someone to take the case: Charles J. Cooper, who ran the Office of Legal Counsel under President Ronald Reagan. Bell found an ordinary Virginia voter to serve as one of the plaintiffs. And since the administration refused to release the list of felons covered by the order, Bell contacted prosecutors around the state for help. They discovered it applied to several violent criminals still in custody as well as 132 sex offenders locked up under civil commitment orders.

Bell’s supporters say those efforts should boost his chances to secure the GOP nomination for attorney general. He faces Richmond lawyer John Adams, a partner at McGuireWoods, which was interviewed about the case but was not optimistic about it, according to Bell supporters.

A campaign spokesman for ­Adams would not say whether the firm had declined to take the case or whether Adams would have played a role in such a decision.

Adams suggested that Bell was trying to take too much credit.

“The victory for this case rests primarily on the shoulders of the lawyer, Chuck Cooper, who is a good friend and supporter of my campaign,” Adams said in a written statement. “Whatever credit elected officials who worked behind the scenes want to take is up to them.”