Earlier versions of this story misstated when John Bowen lost his voting rights for the second time. It was in January. The story has been corrected.

Republican gubernatorial candidate Ed Gillespie on Monday launched a TV ad claiming that Democrat Ralph Northam made it easier for violent felons and sex offenders to get their hands on guns.

The ad is based on outgoing Gov. Terry McAuliffe’s sweeping actions to restore voting and other civil rights to felons. In one of the few states that permanently disenfranchises felons, McAuliffe (D) has restored the right to vote and to serve on juries to more than 168,000 felons who have completed their sentences. His action also helped them over the first hurdle to have their gun rights restored, although the felons still need judges to sign off.

“Last year, Terry McAuliffe and Ralph Northam instituted the automatic restoration of rights for violent felons and sex offenders, making it easier for them to obtain firearms and allowing them to serve on juries,” the ad begins. “One of these felons, John Bowen, had his rights restored two months after being found with one of the largest child pornography collections in Virginia’s history.”

Bowen, of Accomack County, was convicted of aggravated sexual battery and indecent liberties with a minor in 2001 and served a one-year sentence, the Virginian-Pilot reported. Like other felons who had completed their sentences, he had his rights restored under McAuliffe. Bowen lost his voting rights again in January when he pleaded guilty to a new felony, possession of child pornography. He is serving 15 years in prison, the paper reported in June.

McAuliffe (D) on Monday tore into Gillespie for what he saw as an attack on one of his signature achievements in office — one that Northam, as a member of McAuliffe’s administration, has called “one of our greatest feats.”

“It’s based on the same fears and same division we saw from Donald Trump,” McAuliffe said during a conference call with news media that was hastily arranged to respond to the ad. “This is a page right out of Donald Trump’s playbook. . . . He’s gone into the gutter one more time. This is one of the most divisive campaigns I have ever seen.”

“If you look at the ad and the individual he uses in the ad, obviously he is trying to sensationalize the issue,” McAuliffe said. “Ed is trying to divide people and scare people, as he has done this whole campaign.”

The Northam campaign attacked Gillespie for “running one of the most virulently negative and ugly campaigns in recent memory.”

“Since he has no positive ideas, he’s resorted to lying about Dr. Northam,” Northam spokesman David Turner said. “It is a new low for him to accuse a pediatrician and children’s hospice medical director of favoring felons who have hurt children. Ralph believes all Virginians who have served their time and are law-abiding should have their rights restored, and that’s never changed. Ed knows that and should be ashamed.”

Coming two weeks before Election Day, the ad doubles down on the law-and-order theme that Gillespie’s campaign thinks will play well with suburban swing voters as well as conservatives who voted for Trump last year. For weeks, Gillespie has aired ads that seek to blame Northam for the rise of the MS-13 street gang. Critics, including former president Barack Obama at a Northam rally in Richmond last week, have called the ad an attempt at fearmongering.

“What he’s really trying to deliver is fear,” Obama said.

Most public polls indicate that the race will be tight. Political observers are watching the contest — the only competitive governor’s race in the nation this year — as a referendum on Trump and a hint of what could come in next years’s congressional midterms.

Virginia is one of a handful of states that permanently disenfranchises felons.

The Virginia Constitution, however, gives the governor authority to restore the right to vote, serve on a jury and run for public office.

McAuliffe’s predecessor, Robert F. McDonnell (R), simplified and accelerated that process, but McAuliffe took it to a new level. With great fanfare on the steps of the state Capitol in April 2016, McAuliffe announced that he had restored rights to 206,000. He heralded his action as a way for Virginia to move past the Jim Crow era, noting that African Americans have been disproportionately affected by felon disenfranchisement.

A year later, McAuliffe said he had restored more voting rights than any other U.S. governor, calling it his “proudest achievement” in office. But it has been a bumpy road to the record books.

McAuliffe had intended his original executive order to cover only felons who had served their time and completed parole, but he mistakenly restored rights to 132 sex offenders still in custody as well as to several convicted killers on probation in other states.

Republican legislators, furious because the order included violent felons and those who had not paid court costs or made restitution to their victims, filed a lawsuit with the state Supreme Court. The GOP won, with the court ruling that the governor had exceeded his clemency powers because he restored rights en masse instead of individually.

Since then, the governor has used a fast but individualized approach to restore rights to 156,000 felons — a process that passed muster with the high court.