As she marched in Merrimack, New Hampshire’s July Fourth parade, Senator Kelly Ayotte smiled and shook hands with Granite State residents in the hot summer sunshine. But her politician’s charm seemed to shut off when she encountered roughly a dozen demonstrators holding “Disarm Hate” signs. Ayotte kept her face blank and her hands at her sides while she passed in front of the group, before turning warmly to the next cluster of onlookers.

The contingent of volunteers from Moms Demand Action for Gun Sense in America was one small part of an effort by national gun safety groups to help defeat Ayotte, a Republican who is seeking a second term. Her vote against a 2013 bill that would have expanded gun background checks has earned Ayotte the furor of grassroots activists and well-funded political action committees intent on showing that opposition to gun reform carries an electoral price.

On the other side, Ayotte is feeling the scorn of gun rights activists whose protection during campaign season cannot be secured by a single legislative ballot, but instead requires total loyalty. Working the crowd just ahead of Ayotte on the parade route that day was Jim Rubens, her challenger in a September 13 primary. A former state senator, he has worked to build support for his upstart candidacy based on what he and some conservative voters call Ayotte’s insufficient support for the gun rights cause. Opponents who were never convinced of the former prosecutor’s Second Amendment credentials earlier in her New Hampshire political career now criticize her for recent moves backing compromise legislation barring terror suspects from buying guns, and even for casting procedural votes to allow debate on gun bills in the wake of the Orlando nightclub massacre in June. If the gun rights advocates who form a subset of hard-right voters don’t turn out for her in November, Ayotte, who is trailing narrowly in polls, will have an even steeper hill to climb if she is to secure reelection.

Boxed in by harsh critics, Ayotte, a former prosecutor, has taken the same tack on gun policy that she has attempted to navigate with the divisive candidacy of Donald Trump, whom she has refused to endorse, but says she will vote for. (Ayotte declined interview requests for this story.) The tightrope act is a striking turn for a politician who in past election cycles could have expected to gain safe harbor by siding with the National Rifle Association, as she did three years ago on the background check bill. Strategists for the gun reform organizations that are spending heavily against Ayotte hope to not just oust her from her seat. They want to shred the whole playbook that guides many Republicans in moderate states.

Ayotte won election to the Senate in the Tea Party wave of 2010, but her resume up to that point was hardly that of a right-wing firebrand. For the previous six years, she had served as New Hampshire’s Attorney General, a post she was appointed to in 2004 by Republican Governor Guy Benson, then reappointed to by his successor John Lynch, a Democrat. Prior to her Senate race, Ayotte had never before run for office, so few state voters knew what her political views were, local political operatives say.

Ayotte’s record as AG contained entries that both sides of the gun debate could interpret as friendly. Gun rights advocates could take encouragement from the conservative principles at the heart of her most prominent case, in which she successfully sought a death penalty sentence for a man who gunned down a Manchester police officer. Reformers, for their part, were cheered by her decision to join Lynch in opposing a “stand your ground” law, as well as an amicus brief she filed against an effort to make it easier to get a concealed carry permit in the state.

But Ayotte’s Senate career quickly clarified where she stood on the issues. Running for the office in 2010, Ayotte completed a questionnaire from the New Hampshire Firearms Coalition — “the only no-compromise gun rights organization” in the state, as it bills itself — in which she pledged to oppose “any further restrictions on firearms and ammunition.” In her other answers to the gun group, Ayotte put herself on record as favoring even more extreme positions, indicating that she backed allowing guns into schools and repealing a 66-year-old law regulating machine guns.

Three years into her first term, in the wake of the Sandy Hook Elementary School shooting, the most high-profile federal fight over gun regulation since the 1994 assault weapons ban came to the Senate floor. Ayotte found herself on the spot. A bipartisan band of lawmakers had signed on to a bill brought by Republican Pat Toomey of Pennsylvania and Democrat Joe Manchin of West Virginia to require background checks on firearms sales conducted at gun shows and over the internet. Mark Glaze, the former executive director of Mayors Against Illegal Guns, which later became part of Everytown for Gun Safety, said “Ayotte was at the top of the list” of Republicans the group hoped would add their names and put Manchin-Toomey over the top. Ayotte spent the days before the vote wavering as both sides pressed her.

She announced her opposition just hours before the defeat of the proposal. Had Ayotte gone the other way, gun safety proponents stood ready to reciprocate by rallying behind her in her next run. Howard Wolfson, the political adviser to pro-gun-reform former New York City Mayor Michael Bloomberg, said Bloomberg’s political action committee would have “enthusiastically” supported Ayotte’s reelection bid if she had voted for Manchin-Toomey.

At the time, Ayotte’s staff was sharply divided over her vote. But Glaze said that, in the end, her fear that a vote for the bill would prompt a primary challenge won out.

Looking ahead to tough first reelection bids in their Democratic-leaning states — and perhaps looking also at polls showing strong support for expanded background check laws — fellow freshman Republican Mark Kirk of Illinois joined Toomey to vote for the 2013 bill. This year, both, as expected, have drawn potent Democratic challengers in states that Hillary Clinton is likely to win. And thanks to their votes, both senators have won endorsements and donations from the same critics spending millions to bounce Ayotte.

But Kirk and Toomey, whose primaries this year took place in the spring, also had fewer concerns than Ayotte about being attacked from the right. In New Hampshire, a June 10 filing deadline meant that Ayotte had to sweat out much of 2016, with the chance that a stronger primary challenger could jump in if she moved toward the middle on issues including gun laws. Besides Rubens, several prominent conservatives, including New Hampshire House Speaker Bill O’Brien, were rumored to have mulled a primary bid. Last December, after a couple expressing ISIS sympathies fatally shot 14 people at an office holiday party in San Bernardino, California, Ayotte voted against Democratic legislation to block people on terror watch lists from buying guns.

Now, Ayotte’s apparent aim is to find center-right territory in a state where independents make up 14 percent of voters. She wants to be close enough to the NRA and other groups to appease pro-gun activists, but far enough to assert autonomy.

In ads, she calls herself an “independent” voice for New Hampshire residents. With Clinton leading Trump in the state, Ayotte likely needs votes from some Democrats backing Clinton to keep her job. Ayotte herself is in a dead heat with the Democratic candidate, New Hampshire Governor Maggie Hassan, in statewide polls.

Earlier this summer, Ayotte voted to allow debate on the same terror gap bill she voted against last year. She also backed a bipartisan compromise proposal on the issue pushed by Senator Susan Collins, a moderate Maine Republican. In another ad, her campaign now claims that she “voted for background checks” — a reference to an NRA-backed bill with modest provisions that pushed for more prosecutions of people who lie on background check forms.

Gun violence prevention groups aren’t having it: They’ve spent $3.5 million and counting on their negative ads against her. That includes the $2 million in ads taken out by Independence USA, the political action committee funded by Bloomberg, which has attacked Ayotte for supporting Trump. (The Trace receives seed funding from Everytown for Gun Safety, which is partially funded by the former mayor.) Wolfson said in an email that the group focused on the Trump ties because her support for him “popped in the polling as a significant negative for her.” But he indicated that other ads this fall will hit Ayotte on her gun votes.

Americans for Responsible Solutions says ads from its PAC helped push Ayotte’s favorability to below 50 percent. Before the group began airing its spots in late May, the organization’s polling found that three quarters of voters believed that Ayotte “supported background checks;” now only 59 percent of voters do. The same survey found that a plurality of voters (47 percent) are less likely to vote for a candidate who is opposed to background checks for gun sales.

“In the wake of her background check vote in 2013, we said we were going to hold the senator accountable,” said Zach Stewart, political director for the PAC affiliated with Americans for Responsible Solutions.“We want to put our money where our mouth is.”

Ayotte is going to win her primary, but the home stretch of the general election only presents another potential pitfall on the gun issue. In addition to her popular Democratic rival, the November ballot will also features Aaron Day, an independent libertarian-leaning candidate who says he would be glad to siphon off enough votes to help deliver victory to Hassan.

“I’ll probably have the Second Amendment rights people,” Day told The Trace. Ayotte, he alleges, can’t seem “to articulate what her stance should be on gun rights.”

Gun Owners of America, an extreme gun lobbying organization, has attacked Ayotte for backing the Collins compromise on terrorists and guns. Local guns groups are also hostile. The New Hampshire Firearms Coalition has urged its members to tell Ayotte “to keep her hands off the Second Amendment,” and it says she violated another of her 2010 campaign vows — in which she indicated she would make gun rights support a condition for approving of federal appointees — by voting to confirm Attorney General Loretta Lynch. The group has effectively cast its lot with Rubens: In a post sent to supporters after Ayotte’s background checks ad, the group said Ayotte “has become an anti-gun activist.”

Steve Duprey, a former chairman of the state Republican Party, believes New Hampshire is “probably the most strongly pro-Second Amendment state in the country.” He supports Ayotte, but said neglecting gun rights sentiments in the state is dangerous. Duprey cited the example of Congressman Richard Swett, who was defeated in 1994 after he cast a key vote for the assault weapons ban.

But that was 22 years ago. Many political analysts — from both parties — say that New Hampshire in 2016 is radically different.

Andrew Smith, director of polling at the UNH Survey Center, said that despite the state’s “Live Free or Die” motto, polls show that New Hampshire’s libertarian reputation is “a myth.” State residents “are by and large moderate New England voters” on social issues, including guns: 84 percent of voters support universal background checks.

Stewart, of the ARS PAC, said Ayotte’s approach to gun policy is dated. “She has this old school mentality that as long as she appeases the gun lobby, they will have her back. She will be able to keep her head down and avoid taking heat on this issue,” he said. “That hasn’t worked.”

To date, the bulk of the NRA’s federal political spending in 2016 — nearly $2 million in all — has gone toward defeating Ohio Democrat Ted Strickland, who now trails incumbent Republican Rob Portman in that state’s hotly anticipated Senate race by 10 percent.

With Ohio looking less competitive than expected, it’s New Hampshire that may emerge as the proving ground for whether endorsements and money from gun reform groups can rival those of the gun lobby. So far, beyond token contributions, the NRA has devoted little of its war chest to improving Ayotte’s reelection prospects, disclosing less than $50,000 spent on a mailer attacking Hassan.

[Photo: Thomas Roy/Union Leader via AP]