When Tim Kaine was running successfully for governor in 2005, he headed out to Hardy, Virginia, an unincorporated community near the Blue Ridge Mountains, to blast clays with fellow skeet shooters. Kaine had come up in politics as the mayor of Richmond, and he was eager for rural voters to see that he was no gun-grabber, and was in fact handy with a shotgun himself. He told a handful of reporters and spectators that tagged along, “I’m committed to protecting that constitutional right to hunt and fish… I value the traditions that Virginians value.” That election season, Kaine completed a questionnaire from the rabidly pro-gun Virginia Citizens Defense League, in which he indicated that he was opposed to bans on specific types of firearms and supported legal protections for homeowners who use guns to ward off intruders.

But when Kaine ran for Senate in 2012, his campaign reflected his tenure as a pro-gun reform governor, a record born out of both conviction and circumstance: The deadliest mass shooting to date had happened at Virginia Tech just 15 months into his term. While he maintained his support for the Second Amendment, at least on his campaign website, Kaine became a major target for the National Rifle Association, which is headquartered in Northern Virginia. The group drew heavily from its campaign war chest and spent more than $700,000 in its efforts to defeat him, airing ads comparing his gun record to President Barack Obama’s. In 2012, only four other federal candidates drew more financial heat from the NRA.

Despite that opposition, Kaine easily won the Senate race, emerging with 53 percent of the vote.

Last night, Kaine accepted the Democratic vice presidential nomination amid a slate of convention programming that for the party amounted to an unprecedented embrace of gun reform. Sixteen years after the NRA took credit for Al Gore’s loss in his home state of Tennessee — a loss that helped cost him the White House — Hillary Clinton began this cycle by boasting in a Democratic debate that she was proud to have the gun lobby as enemy number one. Now, with Kaine aboard as running mate, the Democrats feel confident that they can turn the tables by topping the NRA-endorsed Donald Trump in the group’s backyard and putting Virginia’s 13 electoral college votes into their column.

That confidence is a product of Kaine’s own triumph in 2012, which Clinton made sure to highlight as she unveiled her VP pick last weekend: “Behind that smile, Tim also has a backbone of steel. Just ask the NRA,” she told a crowd in Miami. Kaine was one of several Democrats to withstand well-funded NRA attacks that year, with Sherrod Brown in Ohio and Bill Nelson in Florida shrugging off barrages of ads in their own states. For the NRA, 2012 was a losing year across the country: Only eight of the 24 federal candidates it opposed ultimately lost, and of the 10 candidates that it spent the most money against, only two went down to defeat. (One of them was centrist Republican Dick Lugar, felled in his Indiana primary.)

The party’s new playbook turns on its head the conventional wisdom that Democrats should avoid the gun issue at all costs. Now, its candidates for federal office are running toward gun reform, rather than backing away from it. But a closer look at recent history in Virginia also shows that in important ways, the party’s ability to outmuscle the NRA depends on when a race is happening, and where.

During his 2005 gubernatorial campaign, Kaine promised on his campaign website that he wouldn’t add any more restrictions on gun rights in the state. But a little more than a year into his term, in April 2007, a gunman opened fire at Virginia Tech, killing 32 people before killing himself. After the shooting, Kaine pushed for stronger gun legislation, and used his executive authority to close a loophole that had allowed gun dealers to sell to those who had been committed involuntarily to a mental health treatment facility. The NRA expressed support for the move.

As Kaine was making his gun safety push, Virginia’s Republican-controlled legislature was passing laws that would have expanded gun rights, only to have them blocked at the governor’s desk. Kaine’s first vetoes were of bills that would have extended where Virginians could bring their firearms: In March 2008, he declined to sign a bill allowing residents to store guns in their cars without a permit, and another permitting guns in restaurants or bars that sold alcohol.

Later in his tenure, Kaine sought to require background checks for gun show sales. A pollster who had long worked for him said that Kaine didn’t see the measure as a new restriction, but rather a fix to a current law. Unswayed by his parsing, the NRA opposed the plan, dooming it to failure as state legislators from more conservative districts refused to break ranks with the group and Virginia’s other state gun lobbies.

In the 2012 Senate race, the NRA gave Kaine an F rating and worked tirelessly to use it against him as he faced off against former governor and Senator George Allen. A large chunk of the $600,000 the NRA spent opposing Kaine went to an ad campaign that highlighted Kaine’s gun record and connected him to figures it deemed to be anti-gun, like Sonia Sotomayor. The ads didn’t stick, and come Election Day, Kaine handily beat Allen.

Kaine’s conservative opponents had had a hard time painting him as a typical anti-gun liberal: He grew up in a blue-collar family and retains an amiable Suburban Dad mien. But in his Senate race, Kaine was also the beneficiary of good timing. Between 2000 and 2010, Virginia’s population grew by 13 percent, with majority-minority populations developing in the state’s metropolitan areas. Crucially, Kaine’s 2012 Senate run also came with the benefit of presidential year’s electorate, when higher turnout among Democratic-leaning constituencies in the northern Virginia suburbs, Richmond, and Norfolk, can dilute the influence of the single-issue voters who reliably show up every election day. In 2012, so many voters headed to the polls that the state election board waited an extra hour before reporting any state results to avoid influencing people still waiting to cast their ballots.

“I think 2005 and 2012 Virginia are two very different animals,” Geoffrey Skelley, a political analyst at the University of Virginia Center for Politics, tells The Trace.

The changes that Kaine benefitted from were significant enough to continue into future statewide elections: In 2013, Terry McAuliffe won his gubernatorial race after calling for an assault weapons ban and universal background checks and bragging about his own failing grade from the NRA. His campaign manager was Robby Mook, who is now captaining Clinton’s quest for the White House.

After fellow Democrat Mark Herring also won his bid for Attorney General in 2013, his campaign manager Kevin O’Holleran took the occasion to puncture the gun lobby bogeyman in an op-ed for the Washington Post. “Voters were calling out for action on gun violence, and they flocked to the candidate who offered progress,” he wrote.

Virginia’s 2015 legislative elections came months after a gunman murdered two former colleagues on live morning television outside of Roanoke. With Democrats needing two seats to win a clear majority in the upper chamber and give McAuliffe the leverage he needed to push his broader agenda, the governor spotted an opening. Less than two months before voters went to the polls, McAuliffe appeared at a gun violence prevention rally in Washington, D.C. In the lead up to Election Day, gun reform groups including Americans for Responsible Solutions and Everytown for Gun Safety (a seed donor to The Trace) spent at least $2.2 million on two select contests.

But the tactics that sent Kaine to the Senate and that have emboldened Clinton’s campaign this year have yet to include a reliably winning diagram for the smaller races that elect the lawmakers who shape much of gun policy today: Democratic candidates won only one of the targeted 2015 state Senate races, falling short by fewer than 1,500 votes in the second contest the party needed to win in order to flip the chamber. Lacking the diversity and scale of a statewide electorate, smaller state-level districts remain susceptible to the sway of groups like the NRA. (Uncoincidentally, Republicans currently hold more state legislative seats nationwide than at any time in the past 50 years.)

At the rally in D.C. that fall, McAuliffe declared he was “sick and tired of gutless politicians who are scared of the NRA.” Just four months later, he was left to compromise with some of the group’s staunchest Republican supporters on a package that reform advocates felt gave away much more than it gained. In January, with McAuliffe confidantes leading the talks, Virginia entered into a concealed-carry reciprocity deal with 25 other states, in exchange for modestly stricter gun rules for domestic abusers — a deal that was partly negotiated with NRA lobbyists at an oyster dinner. That meal, which took place just days before the agreement was announced, was intended to remind both sides of the political stakes at hand.

[Photo: AP/Cliff Owen]