House Speaker Paul Ryan’s primary race is a reminder of why most House Republicans avoid legislation with even the faintest whiff of gun control attached.

Before the July Fourth recess, Ryan acceded to pressure from both parties and announced a plan to vote on legislation intended to restrict terror suspects’ access to guns. Ryan’s plan failed fast when conservatives rebelled, forcing the Speaker to scrap the vote. At the heart of that insurgency was the House Freedom Caucus, a group of about three dozen conservative Republicans who routinely wage war against their party’s leadership.

In addition to giving Republican leadership fits, Freedom Caucus objections can boost primary challenger’s attacks on sitting House members — even those with strong conservative records. Not long after the caucus successfully scuttled Ryan’s proposed vote on the terror gap bill, Paul Nehlen, who is taking on Ryan in Tuesday’s primary, began adopting the group’s stance to bash Ryan on guns, while also accusing Ryan of failing to side enough with Republican presidential nominee Donald Trump.

In a speech last week, Nehlen declared that the Second Amendment “must be protected from the assaults of career politicians looking for an emotional tabloid headline.”

Ryan is expected to triumph in the primary, but after the surprise primary defeat of House Majority Leader Eric Cantor in 2014, Republican leaders, even popular and reliably conservative ones, are extremely reluctant to defy the far right wing of the party. Their fear has given the Freedom Caucus power to define the boundaries of what Republican leadership will do — and, by extension, what Congress can accomplish.

The Freedom Caucus formed in January 2015 to oppose what its nine founding members called excessive acquiescence of their leaders to Democrats. Its invitation-only membership, which includes former Tea Party officials, was deliberately set to be just large enough to ensure that opposition from the group denies Republican leaders enough votes from their own party to pass bills.

Freedom Caucus members are not indifferent to Ryan’s political considerations: They are actively hostile to them. They labeled the prospect of a vote on the terror gap bill an example of GOP leaders compromising conservative ideals.

That’s because the Freedom Caucus exists to oppose, not legislate. Its members seek symbols to show disaffected conservatives they are with them against the GOP establishment. (The group was instrumental in helping oust former House Speaker John Boehner.) Though the caucus’s main focus is fiscal — it opposed Ryan’s budget plan this year, embarrassing House GOP leaders — members also hold a hard line on the Second Amendment. Its chairman, Ohio Representative Jim Jordan, has for instance pushed legislation blocking District of Columbia gun restrictions and barring D.C. city councilors from enacting new ones.

A no-compromise position on firearm regulation is an effective means to signal to constituents in group members’ mostly exurban or rural districts that they are working in their interest — even when large majorities of Americans say they favor a specific gun reform.

On June 12, a gunman slaughtered 49 people at a gay nightclub in Orlando. The shooter, Omar Mateen, declared allegiance to the Islamic State during the attack. He had previously been on an FBI terror watch list, though his name had been removed before he bought the weapons he used in the attack.

Polls conducted shortly after the mass shooting showed that around 80 percent of Americans supported legislation to bar people on a federal “no-fly” list from buying guns.

In the aftermath, politicians from both parties introduced legislation intended to close the “terror gap,” the loophole that allows people who are on a terrorist watch list to purchase guns from a licensed dealer.

In mid-July, after a month of national headlines about the issue, Ryan scheduled a vote on a bill that would have imposed a high burden on law enforcement officials attempting to deny a sale. The measure would have allowed the Justice Department to block the sale of a gun to a person on a federal terror watchlist only if the department could, within 72 hours, show probable cause that the suspect might participate in an act of terrorism.

Democrats said the bill would have put too big a burden on federal agents, and preferred terror gap fixes that would have added watch-listed individuals to the databases of persons prohibited from firearms purchases.

The failed Republican bill would have been the first legislation to even marginally tighten gun laws to advance in the House since the party took over the chamber in 2011. It had support from the National Rifle Association, all but a few Senate Republicans, and many House Republicans, and was the most conservative of the various congressional proposals to close the terror gap. The vote would possibly have given political cover to Republicans in tough reelection fights after a Democratic sit-in and other moves highlighted Republicans’ reluctance to take legislative action after the Orlando shooting.

The Freedom Caucus said no. For members, the legislation offered an opportunity: to follow through on pro-gun pledges to voters and resume an ongoing battle with party leaders.

In a July 5 Facebook post, Michigan Representative Justin Amash said the terror gap bill would be “among most egregious gun control measures ever to pass either house of Congress” and “mark a massive expansion of the government’s ability to restrict gun rights on the basis of precrime—a crime not yet committed.” The Michigan Republican called the proposal “the actualization of dystopian fiction.”

Using guns as a proxy for conservative purity is the very strategy that then-unknown candidate David Brat used to defeat Cantor in 2014. Brat, who became a founding member of the Freedom Caucus, pulled off the primary upset with a boost from the Virginia Citizens Defense League. The gun rights group was irked that Cantor blew off a questionnaire asking him to reaffirm support for the Second Amendment — even though Cantor had support and an A+ rating from the NRA.

The ascendency of the Freedom Caucus, and ultra-Republican conservatism in general, is a function of an electoral landscape where districts have been drawn to ensure one-party dominance.

Cantor’s former central Virginia district votes 10 percent more Republican than the U.S. as a whole, which is average for a Republican-represented district. In such districts, where Democrats do not strongly compete, primaries are often more dangerous for Republican lawmakers than general elections.

Freedom Caucus districts are more conservative still. Among Republican voters in those districts, 84 percent said they thought it was more important to protect gun rights than control gun ownership, compared to 77 percent of Republican voters in a typical GOP House district.

This high degree of partisanship helps explain why most House Republicans, even members of the conservative Republican establishment that broadly supports Second Amendment rights, fear facing a primary challenger supported by extreme gun-rights groups like National Association of Gun Rights and Gun Owners of America. If Cantor could lose a primary challenge, so could they.

Both gun groups back long-term Arizona Senator John McCain’s primary challenger, Kelli Ward, who has vowed to try to repeal all federal gun laws.

In Arizona, GOA called McCain a “gun-grabbing globalist” in a radio ad ripping him for backing bans “on certain handguns” and upholding restrictions on firearms on military facilities. “Gun Owners of America is calling on all freedom-loving people to unite in support of Dr. Kelli Ward,” the ad says.

NAGR also endorsed Ryan’s opponent ahead of their Tuesday primary.

The group has taken credit for defeating the terror gap bill. “We not only killed it, but we peed on the fence post when it was dead,” the head of NAGR told The Huffington Post.

One possible result of using elected office to wage war against elected officeholders, as the Freedom Caucus has done, is that voters may come to agree too much with your message. Facing a tough primary challenge this summer, Representative Tim Huelskamp of Kansas, a caucus member, touted support from the NRA and Gun Owners of America. He released a video that shows him shooting an AR-15 at a target with “Back Door Bullet Bans” written on it.

It wasn’t enough. Ads had described Huelskamp, who sparred publicly with GOP leaders, as a Washington insider. He lost his primary challenge on Aug. 2.

[Photo: AP/J. Scott Applewhite]