Gov. Terry McAuliffe’s sweeping order to restore voting rights to ex-felons may have had another unintended consequence: giving the right to vote to at least 132 sex offenders who have finished their sentences but remain locked up because they have been deemed too dangerous to release.

In Virginia, such individuals can be sent through a civil court proceeding to the Virginia Center for Behavioral Rehabilitation in Nottoway County, southwest of Richmond.

Nottoway Commonwealth’s Attorney Terry J. Royall said Wednesday that 176 of the center’s 370 residents have regained the right to vote, run for public office and serve on a jury.

She said she was told by the facility director that there are 176 residents who “meet the governor’s criteria for restoration . . . Today his staff ran those 176 names through the database and 132 came up as having actually been restored.”

[The race-infused history of why felons aren’t allowed to vote in 12 states]

Virginia Gov. Terry McAuliffe made a decision to allow convicted felons to vote ahead of elections in November. Here’s how the executive order works and why it has lead to a legal fight. (Claritza Jimenez/The Washington Post)

The facility director, Jason Wilson, could not be reached for comment Wednesday night. But Royall said she looked up the name of one VCBR resident on a state website and was able to confirm that his rights had been restored.

In a letter to county supervisors, she noted that such residents “are civilly committed because they have been adjudicated to be sexually violent predators by a circuit court judge. Moreover, they will have to be transported at taxpayer cost when they choose to exercise their Constitutional rights to vote and/or serve on a jury.”

But McAuliffe spokeswoman Christina Nuckols said that the governor’s executive order does not cover residents at the facility. She accused Royall, an independent, of joining a Republican effort to “demagogue this issue.”

“The governor’s restoration order specifically excludes individuals who are under any form of supervised release, and offenders in this facility are clearly under 24-7 supervision by the state,” Nuckols said. “None of them had their rights restored, plain and simple. This is yet another partisan attempt to spread misinformation and hysteria.”

[In Virginia, a rush to register 200,000 felons]

Royall and others pushed back, noting that the residents in question are not under “supervised release” — even though they are under tight supervision. The governor’s order makes no explicit provision for excluding people who have been civilly committed.

“Civil commitment is not part of a criminal sentence, even though they are still in custody,” said Steve Benjamin, a prominent Richmond defense attorney.

Del. Robert B. Bell (R-Albemarle), who is running for attorney general in 2017, described the continued confinement of the residents deemed dangerous as “a post-sentence civil procedure.”

“I understand his desire to go to the wayback machine and modify his order yet again,” Bell said of McAuliffe. “But this ­happened.”

With great fanfare, McAuliffe in April restored voting and other civil rights to more than 200,0000 felons who had completed their terms of incarceration or “supervised release, including probation and parole.”

He said the order would help offenders fully rejoin society and help Virginia move past the Jim Crow era, since African Americans have been disproportionately affected by felon ­disenfranchisement.

[Republicans blast McAuliffe over errors on clemency]

Republicans called the move a political favor to McAuliffe’s close friend and political ally, Hillary Clinton, the presumptive Democratic presidential nominee. They filed a lawsuit questioning McAuliffe’s constitutional right to restore rights en masse, instead of on a case-by-case basis as previous governors had done.

In recent weeks, Republicans and some law enforcement officials have said that the governor’s rights-restoration process was rushed and riddled with mistakes. For example, McAuliffe mistakenly restored voting rights for several violent felons in prison or on supervised probation. He also has acknowledged that he did not consider that the restoration order would make it easier for felons to apply to have their gun rights restored.

McAuliffe has said some errors were unavoidable with such a large undertaking and pledged to correct them.