A flyer/mailer distributed by the NRA Institute for Legislative Action supporting Ed Gillespie, Republican candidate for the U.S. Senate in Virginia. (National Rifle Association)

The National Rifle Association last week launched a multimillion-dollar ad campaign to cut down Michael Bloomberg’s gun-control efforts focusing on states with key Senate races, including Virginia.

In addition to airing TV ads in several states, the NRA blanketed its home state — the group’s headquarters is in Fairfax County — with direct-mail material touting Republican Ed Gillespie, the former lobbyist who is running against Sen. Mark R. Warner (D). Gillespie, the mailer says, is the antidote to the “Obama/Bloomberg gun control agenda.” And more are expected.

The ad could have unintended consequences for Gillespie, who secured the nomination in part by courting tea party conservatives but who is now trying to woo more-moderate general-election voters.

Gillespie risks alienating the electorate in vote-rich Northern Virginia who may be turned off by Second Amendment rhetoric, especially after mass shootings at Virginia Tech in 2007 and an elementary school in Newtown, Conn., in 2012.

Gov. Terry McAuliffe, taking advantage of Virginia’s changing political landscape, last fall became one of the first Democrats in recent memory to win statewide office while strongly supporting gun restrictions. Yet the NRA is just as sure of its winning strategy as Democrats have been of theirs — evidence that both sides are testing what messages will work in an evolving swing state.

A front of a flyer mailed by the NRA Institute for Legislative Action supporting Ed Gillespie, Republican candidate for the U.S. Senate in Virginia. (National Rifle Association)

One side of the NRA mailer pictures the former New York mayor and President Obama and the warning “Restricting your Second Amendment right is Obama’s unfinished business!”

On the flip side, a smiling Gillespie appears alongside his pledge to “strongly oppose and fight against” Obama’s “anti-gun nominees for the U.S. Supreme Court,” a U.N. gun ban treaty, any bans on guns and ammunition, a federal gun registration database and government approval for gun sales among friends and family.

The NRA’s Institute for Legislative Action, which produced the ad without coordinating with Gillespie’s campaign, said the message works no matter where voters live. NRA-ILA spokesman Andrew ­Arulanandam confirmed that the mailer was sent to all geographic regions of the state. He declined to put a price tag on the effort.

“The Second Amendment is a fundamental constitutional right, and a fundamental constitutional right is never a liability, whether it’s in Northern Virginia or anywhere else in the country,” he said.

Recent polling results don’t necessarily support that position. According to a Washington Post poll conducted in Virginia last year, central and western Virginians are the most receptive to the NRA’s message, with nearly half of voters there saying it’s more important to protect the right to own guns than to enact laws to limit gun violence.

But among those who live in the D.C. suburbs and Hampton Roads, just over a quarter of voters said protecting gun rights was more important than violence prevention. Virginians from these regions favored new gun restrictions by a 2-to-1 margin.

Del. Scott A. Surovell (D-Fairfax), who serves on the House of Delegates’ Militia, Police and Public Safety Committee, said the divide between urban and suburban areas and rural Virginia is clear on gun issues, beginning with the trauma of the D.C.-area sniper shootings in 2002.

“In this partisan environment, people are trying to jack up their base,” he said. “The NRA — if that’s what they’re doing here — they’re sure not going to get any moderate or crossover voters excited about their candidate when they talk about opposing reasonable gun-safety laws.”

But Philip Van Cleave, president of the Virginia Citizens Defense League, said the opposite is true.

“It’s definitely becoming a ­hotter-button issue in the state,” he said. “A lot of [politicians] are trying to steer clear of talking about gun control. It can backfire on them. Gun ownership is on the rise in Virginia as it is across the nation.”

Van Cleave cited the U.S. Senate’s inability to muster enough votes for gun control even after the parents of the children killed in Newtown lobbied lawmakers.

Gillespie’s Web site makes only brief mention of his gun policies, and his campaign issued one sentence in response to questions about his platform.

“Ed would stand up for our 2nd Amendment individual rights in the U.S. Senate, and he appreciates the strong support he has from Sportsmen and supporters of the 2nd Amendment,” campaign spokesman Paul Logan said in a statement.

Warner’s campaign declined to comment on the NRA mailings or his view on guns. As a former governor seeking a second term in the Senate, Warner has a complicated relationship with gun issues.

When Warner ran for governor in 2001, the NRA sponsored a table at the state Democrats’ Jefferson-Jackson Dinner, Surovell recalled. When he ran for Senate in 2008, the NRA gave him an A — a grade the group says has expired; new rankings will come out soon.

After the Newtown shooting, Warner declared his support for some gun-control measures and said, “There’s got to be a way to put reasonable restrictions, particularly as we look at assault weapons, as we look at these fast clips of ammunition.”

Yet four months later, his votes tell a different story. He voted against bans of high-profile assault weapons and high-capacity magazines, and he supported efforts to protect gun owners’ privacy and grant rights to carry concealed weapons across state lines.

He did, however, vote for an unsuccessful compromise that would have expanded background checks for firearms purchases. (Gillespie’s campaign said he would have voted the same as Warner on each issue except expanding background checks, which the Republican opposes.)

While Warner has walked a sometimes-awkward line, McAuliffe has capitalized on Virginians’ changing point of view by embracing calls for tougher gun restrictions. Bloomberg’s Independence USA political action committee gave McAuliffe’s campaign $1.75 million for ads in the final days of the governor’s race, according to data provided by the nonpartisan Virginia Public Access Project.

The NRA’s Arulanandam said McAuliffe’s lead over Republican gubernatorial candidate Ken Cuccinelli II began to erode when those ads hit the airwaves — although Cuccinelli said the close race came down to the Affordable Care Act, not gun control.

Either way, McAuliffe sought to shore up his base quickly after taking office. He tried to amend a GOP-backed handgun bill so that Virginians who stored guns in their cars had to do so in “locked” containers. But after House Republicans rejected his amendment, he vetoed the bill.

The debate over the most minute details in gun legislation shows how important voters on both sides of the issue are to politicians in Virginia and around the country.

The NRA began its campaign attacking Bloomberg with a $500,000 TV ad buy for spots airing in several states. It also plans digital ads in Colorado, Iowa, Louisiana, Nevada, Kentucky, North Carolina and Georgia.

Gillespie remains behind Warner by double digits in recent polls, but the NRA is paying attention to Virginia. Asked why other NRA priorities such as prosecuting criminals and fixing the nation’s mental health system were not mentioned on the Gillespie ad, Arulanandam said: “Who says that’s going to be our only mailer?”

Scott Clement and Peyton Craighill contributed to this report.