In May 2016, the National Rifle Association endorsed Donald Trump for president earlier in the campaign cycle than any candidate in the group’s history. The anointment came during the group’s annual meeting in Louisville, Kentucky, where top NRA lobbyist Chris Cox declared that the “the choice for gun owners in this election is clear. And that choice is Donald Trump.”

The move puzzled observers who understood the NRA to be a doctrinaire single issue interest group, and even some of its own members, who didn’t quite share their leaders’ ardor for the Manhattan businessman.

Trump bore little resemblance to the lifelong heartland conservatives whom the NRA typically backed. He was an Ivy League-educated real estate heir with a gold-plated private jet and a foreign, former-model third wife. Trump and Melania had wed at a glamorous ceremony where Bill and Hillary Clinton had been among the guests. A proud New York City resident, Trump didn’t seem to have much regard for the attachments many Americans felt towards guns, never mind the policy purity the NRA demands of other candidates. In a 2000 book, he’d even written, “I support the ban on assault weapons and I also support a slightly longer waiting period to purchase a gun.”

But from the outset of his campaign, Trump adopted an incendiary message that matched the NRA’s own. He hurled invectives at establishment politicians in both parties. He described a once-great nation under assault and in sharp decline, rhetoric that electrified white Americans brimming with grievance.

In the speech declaring his candidacy, Trump argued elder statesmen from both major parties were indifferent to the struggles of everyday people. “You need somebody, because politicians are all talk, no action,” he said. “Nothing’s gonna get done. They will not bring us — believe me — to the promised land. They will not.”

It was a pitch that found a welcome audience among Americans primed by years of bilious NRA rhetoric. Rage at elites has long been the crucial context for the organization’s gun rights message, the force it has used to mobilize its membership. It’s not just that gun rights must be protected, NRA leaders argue — it’s that they must be defended from political leaders and journalists who have contempt for everyday people’s values and ideas of how America should look.

“Something has gone terribly wrong in our country,” the group’s executive vice president, Wayne LaPierre, said at its 2012 annual meeting, held in St. Louis. “Almost every aspect of American freedom is in some state of decline.” The NRA alone, he declared, stood ready to lead the fight against tyranny imposed by the “global elitists and all their friends in the White House” who were conspiring to “hide the truth we all know in our gut.” Of course, LaPierre sniped, “No politician in any party will tell you that.”

Trump was all about voicing gut-level truths. He was certainly not a conventional politician.

In the six months that followed the Louisville convention, the NRA broke its record for federal election spending, pouring more than $30 million into advertisements meant to help Trump overcome Clinton’s larger war chest and more professional campaign team. Training those ads on rust belt cities and rural parts of swing states, the group hammered Clinton not only as a threat to gun rights, but as an entitled, out-of-touch, career politician disinterested in the concerns of people like them.

It seemed like a terrible bet. Poll after poll showed Trump trailing. Other special interest groups that typically mobilized to elect Republicans stayed home, while growing numbers of conservative journalists and GOP office holders recoiled. Down ballot, congressional Republicans faced an unprecedented struggle over whether or not to disavow their own party’s presidential nominee.

In the wake of Trump’s gobsmacking victory, the NRA’s headlong support of the controversial Republican candidate no longer looks so rash. One interpretation of an outcome that even Trump’s own campaign didn’t see coming, as suggested by late stage insistence on voter fraud and a “rigged” election, is to conclude that the NRA got lucky. Terrified that Clinton would get elected and make good on her promises of gun reform, the group threw money at the race and drew an inside straight.

But the NRA isn’t known for luck — it’s known for ruthlessly effective political strategy, which for decades has kept candidates it likes in power and universally popular laws it opposes off the books. It has done so by maintaining a close relationship with its large, engaged member base, whose votes politicians fear if they cross the NRA on its core positions.

What has gone less noticed is how the group has succeeding in stoking populist furor that spills well beyond the people on its email list.

“Both the NRA and Trump promote a nostalgia for something that has been lost,” sociologist Scott Melzer, author of the 2012 book Gun Crusaders: The NRA’s Culture War, tells The Trace. The gun group and its candidate speak to “this white rural conservative population that feels left behind by economic shifts and cultural shifts. These changes pose a threat to their identity.”

Melzer says the NRA has figured out how to mobilize people by fostering a sense that they are threatened by outsiders. “That makes them the most effective social force in conservatism, and they’ve done so with language that Trump used,” he said. The NRA seized on this rhetoric to fuel its interest group politics.

Trump brought it to the larger arena of mainstream politics, then rode it to the Oval Office.

The NRA was once an apolitical hunting and sportsmen’s group. But even after its transformation into a full-fledged political operation, the organization’s rhetoric usually focused on its core issue of Second Amendment rights.

In 2008, with Republicans in danger of being swept from power at the end of the Bush presidency, the group was in a newly embattled position. That May at the group’s annual meeting, LaPierre defined the enemy that Americans faced. It wasn’t just burdensome gun regulations, it was the entire class of people who sought to impose them: journalists, Democrats, even celebrities like Rosie O’Donnell. The ruling establishment, he declared in front of a blood-red backdrop, “all believe the same elite conceit — you shouldn’t protect yourself. Government should.”

“But we know there’s a little problem with that,” he continued. “They don’t give a damn about you!”

Four years later, LaPierre expanded on the threats the elite posed to encompass free speech, religious liberty, even the ability of people to start small businesses or choose for themselves what kind of health care they want. Drug dealing illegal immigrants were being allowed to pour over the Southern border, he railed. Criminals in big cities were free to prey on innocents because judges were so lenient.

“Not our issues, some might say.” He paused, and then countered: “Oh, but they are.”

In 2012, LaPierre’s message did not resonate widely enough to prevent the reelection of Barack Obama, whose victory cemented a conventional narrative that America was on a long march toward more progressive social and economic policies. The Republican establishment was among the staunchest backers of big business and free trade. The presidential candidate the party put forth that year, Mitt Romney, was a product of the same elite the NRA told its members to despise.

The anti-establishment strain of the NRA’s messaging was an awkward match for Romney. But as Harry Wilson, a political scientist at Roanoke College, notes, “it fits with the Trump message” — perfectly.

Trump’s brand of pitchfork populism outweighed any concerns the group might have had about his gun rights orthodoxy. The NRA is famously ruthless when it comes to punishing Republicans and the rarer Democratic allies who cross it, but it is not necessarily as rigidly dogmatic as many may think.

Two 2016 Republican contenders managed to climb back into its good graces after acts of apostasy. John Kasich was assigned an F grade after supporting the 1994 assault weapons ban as a congressman, then worked his way back to an A by rapidly expanding concealed carry rights as governor of Ohio. Marco Rubio was lowered to a B+ after opposing a bill that would have required businesses to allow employees to stash guns in their cars in parking lots. He reportedly asked for a re-grade and got back up to an A, before this cycle.

Notwithstanding the sincerity of Trump’s newfound passion for gun rights, he had clearly learned the NRA’s cues by the time he dove into his 2016 run. After ISIS terrorists armed with AK-47s rampaged across Paris last November, he asked whether France’s strict gun laws prevented victims from stopping the killers, echoing LaPierre’s post-Sandy Hook argument that the “only way to stop a bad guy with a gun is with a good guy with a gun.” In January, Trump promised grandly that he would eliminate gun free zones in schools and military bases on his first day in the White House.

Committed gun rights ideologues like Larry Pratt of Gun Owners of America remained skeptical even after Trump eliminated his final primary rival, Ted Cruz, a protege of a top gun rights lawyer and GOA’s pick in the race. While accepting the NRA’s endorsement, Trump underscored that he’s no gun guy at heart. Talking about his sons — who like to hunt exotic game in Africa, not deer in Appalachia — and said he was even “concerned” by the size of their arsenals.

The NRA could look past the fact that Trump doesn’t seem to care much about guns because of his talent for translating its larger mission onto the stage of a presidential campaign: inciting populist anger.

The NRA has pushed its anti-establishment message though it sometimes risks alienating conservatives. In 1995, LaPierre infamously called federal law enforcement officers “jack-booted thugs” in a fundraising letter circulated after several confrontations between officers and armed extremists. Former president George H.W. Bush left the NRA in disgust after that incident.

The NRA’s rhetoric only grew more uninhibited, as exemplified by its embrace of rock musician Ted Nugent as one of its most prominent mascots. Speaking at the group’s 2005 meeting, he called for violent vigilantism: “I want the bad guys dead. No court case. No parole.”

When Trump brought the same violent rhetoric and disregard for political manners into the presidential race, pundits and some fellow Republicans winced. His disapproval ratings reached 70 percent in an ABC News/Washington Post poll in mid-June. Congressional Republicans like Paul Ryan began to pitch themselves to supporters as bulwarks against a likely president Clinton — not as supporters of a supposedly doomed candidate Trump.

Adding to the doubts about Trump’s prospects were the slapdash nature of his campaign infrastructure. He was indifferent to fundraising and voter turnout efforts. By August, the Clinton campaign had spent $52 million on TV ads. The Trump campaign had spent exactly nothing.

As elites from both sides of the ideological divide wrote Trump off, the NRA stood almost alone at his side.

At the end of June, the NRA rolled out its first barrage of anti-Clinton ads. The first, notably, had nothing to do with guns. It featured Mark “Oz” Geist, a former Marine who served at the U.S. consulate in Benghazi where ambassador Chris Stevens and three other Americans were killed in 2012. After a year-and-a-half-long congressional investigation, Clinton had been cleared of accusations of wrongdoing last fall, and Washington had largely put the subject aside. But her apparent ability to get away with what some conservatives called murder did not sit well with working class voters, who saw this as yet another example of an elite politician abdicating responsibility.

One female union construction worker in a suburb of Dayton, Ohio, told ProPublica’s Alec MacGillis that Benghazi was part of what made her turn on Clinton. Another 18-year-old female voter in Pennsylvania told him that she didn’t like the Democratic nominee because the four victims of the attack “weren’t her priority.”

In early August, the NRA paid for another commercial that called Clinton a hypocrite: “She’s been protected by armed guards for 30 years,” a gravelly-voiced narrator said, “but she doesn’t believe in your right to keep a gun at home for self defense.” The Benghazi and “Hypocrite Hillary” ads ran in industrial cities including Columbus, Ohio; Greensboro, North Carolina; and Scranton, Pennsylvania.

“The anti-Hillary aspect to those commercials was humongous, because I know for a fact that many voters voted Trump just to keep Hillary out,” says Nick Stamp, an 18-year-old Trump supporter from a suburb of Youngstown, Ohio. “It was very effective in that sense.”

In Dunn, North Carolina, Mary Godwin says she connected with women in other NRA commercials who were depicted as defenseless under a heartless Clinton presidency. One ad released at the end of September instructed viewers, “Don’t let Hillary leave you protected with just a phone.” It showed a woman waking up in the middle of the night to the sound of a burglar breaking into her home; she calls 911, and unlocks her gun safe — which then disappears for effect.

Godwin is a 27-year-old sexual assault survivor and mother of two young boys. Her husband works until 1 a.m.

“When I cut the TV on and wasn’t watching Netflix or something like that, I saw an NRA commercial. I remember seeing at least two or three a day,” Godwin said. She voted for Trump.

In October alone, according to the Center for Public Integrity, roughly one out of every 20 television ads in Pennsylvania was paid for by the NRA. That same month, the group financed one in nine ads in North Carolina, and one of every eight in Ohio. By Election Day, the NRA had run more than 10,000 ads in the three states. Trump swept them all.

All told total, the NRA ran 14,257 television spots in their effort to elect Trump, according to a Center for Public Integrity analysis of ad data provided by Kantar Media/CMAG.

By the Friday before the election, Clinton was considered the overwhelming favorite to win the White House. That morning, the NRA issued a familiar call to its millions of members: Vote for Trump not just to protect gun rights, but to stick it to the establishment.

“Time after time, the mainstream media has tried to write off Donald Trump and his supporters,” the group said November 4th blog post. “But the media and the Clinton campaign (to the extent they can even be separated at this point) don’t get to write the final chapter to this story. You do.”

[Photo: Angelo Merendino/Getty Images]