Brian Umana is a writer and consultant who grew up locally and was educated at Thomas Jefferson High School For Science and Technology, Stanford, and UVA.

People are baffled today that Rep. Eric Cantor, the House majority leader, lost his job when he lost his GOP primary Tuesday night. A common refrain is, how could this have happened? (Sample headline: “Why Did Cantor Lose? Not Easy to Explain.”)

The truth is that Cantor’s electoral demise did not occur overnight. It was the culmination of more than four years of grass-roots organizing, from both the right and the left, to unseat him. Behind the scenes, Cantor opponents who otherwise had little ideological common ground cooperated in his demise. I know, because I helped engineer it.

In 2010, I managed the general election campaign of Cantor’s Democratic opponent. I never expected us to win, but I was a 27-year-old looking to get involved, and I thought we could achieve some good even by losing the race. (I have since disengaged from partisan politics.) At that time, an “Anyone But Cantor” mentality was beginning to take hold in central Virginia and the Richmond suburbs. In this heavily Republican district, many Democrats and Republicans told me in conversations that they saw Cantor as a disingenuous political insider looking out for his own self-interest above the interests of his constituents.

Still, he didn’t have a heavyweight challenger that year, nor the following cycle. In 2010, on Cantor’s right flank was the self-identified tea partier Floyd Bayne, who had gained ballot access by winning the nomination of Virginia’s oddly named Independent Green Party. Many Bayne supporters would go on to become organizers for Dave Brat, and Bayne’s campaign manager, Tammy Parada, became the independent consultant (and Chesterfield County coordinator) who designed Brat’s election model.

The 2010 midterms were a Republican romp. Even so, Cantor didn’t have a great showing. In October, our campaign found that only 51 percent of voters responded that they would vote for Cantor if the election were held on the day of the poll.  We also found low enthusiasm among Cantor supporters. Tellingly, his camp did not dispute the results of our polling, run by campaign political director Jonathan Stevens, a scientist trained at Princeton with a knack for designing exceptional polls. In November 2010, Cantor was held below 60 percent of the vote for the first time in a general election during his electoral career. Bayne, the tea partier, spent only some $18,000 but still earned between 6 and 7 percent. The 2011 Virginia redistricting made slight changes to the congressional district, but the Republican legislature clearly intended to protect VA-07 as a “safe seat” for Eric Cantor.

After Cantor’s 2010 victory, a group of anti-Cantor activists from both left and right met in person to discuss campaigning against the man who would soon be majority leader. We met several times over two weeks at coffee shops and pubs in strip malls throughout the Richmond suburbs. At first, we were suspicious that one side was trying manipulate the other, but soon we developed a sense of trust over our shared frustrations with Cantor. (For example, we saw his refusal to acknowledge or debate his opponents as condescending to his constituents.) And we agreed that the 2010 results had proved Cantor’s eventual vulnerability. We weren’t some diabolical, well-organized conspiracy to bring him down, so much as a few scattered—if motivated—people talking about their failure to have done so.

Then we started discussing tactics. The tea partiers already knew how to mobilize the folks who showed up at tea party meetings: what they needed was a way to find supporters or potential supporters who were unlikely to bother with regular meetings. Stevens and I thought that a more organized attack from the right could help Democrats, too—either by prompting a future three-candidate race (which might give the Democrat a fighting chance) or by inducing a competitive Republican primary challenge that would force Cantor to burn cash protecting up his flank that might otherwise be spent on competitive races elsewhere. (A primary campaign resulting in Cantor’s defeat, of course, hardly crossed our minds. When Parada mentioned it, I recall calling the possibility “fanciful.”) Stevens and I saw no harm in mentioning strategies that tea partiers might use to reach sporadic Republicans or far-right “independents” who were less likely to support Cantor than other Republicans. We shared data-science techniques for voter targeting and for evaluating the relative cost of earning the votes of different types of voters.

There was a problem: the-easiest-to-use political data is owned by the two major political parties. The Democratic campaign was over, so how could we ethically share information that we thought would serve the greater good? Stevens used his statistical knowledge and near-photographic memory to work from crude, publicly available State Board of Elections data, then manipulate those data into targeted sets of voters more like those that would be available to a large campaign from one of the two parties. He created tidy data sets of voter information and preferences of a sort typically unavailable to independent or insurgent campaigns opposed by a party establishment (like Mr. Brat’s this year). Some techniques like Stevens’s had been used by Obama’s presidential campaign—which Stevens worked on in 2008—but they had not been widely adopted by Republicans, let alone tea partiers without access to the big party databases. Now Parada, who was at our post-election meetings in 2010, knew how to use them.

And as a consultant to the current campaign, use them she did. She and Brat’s staff harnessed data to target the persuadables and upset the establishment.  “This was on the horizon for years,” she e-mailed me to say this week. “This was the direct result of active participants working together across party lines. An unpopular but honest truth in [the] VA7 victory: Mr. Umana and Mr. Stevens, even as their political ideology is far left of conservative, were important players, offering strong analytics behind ‘the numbers’ that eventually led to Cantor’s defeat.”

After 2010, I went on to do other work, and I tuned out of local politics in Virginia’s 7th District until a few months ago, when Brat’s chance of a primary victory caught my attention. Virginia’s 7th District tea partiers are true believers. They never tuned out, and they worked every lever of power they could find. Even though their candidate in 2012 had no money (it still costs something to implement voter-targeting models) and made no significant progress, Bayne, Parada and others urged their supporters to join their local Republican committees starting in 2011, as a way of gaining institutional power.

It’s no coincidence that Cantor failed in a May GOP convention to keep his own supporters in positions of authority: Linwood Cobb, Cantor’s choice, was easily defeated in the vote for Republican Party congressional district chairman. Congressional district chairs can hold significant sway over primary ballot rules, mailing lists of local activists, and use of party voter databases, so it is unusual for an elected chairman not be a big supporter of his or her political party’s local congressman. Eventually right-wing celebrities Ann Coulter and Laura Ingraham also weighed in to endorse the no-name Dave Brat.  Finally, the tea partiers used skillful voter targeting to find the primary voters whom they needed — a development I am partially responsible for.

Was my deal with the tea party an even trade? On one hand, Cantor used his power in the federal government to weaken our country and to make our politics more acrimonious, and I think one more tea party backbencher in the House, provided that House does not include Eric Cantor, is a good deal for Democrats. On the other hand, I had not realized that the tea party in Virginia could field a candidate as skilled as Dave Brat appears he may be. Parada and her right-wing friends clearly had a few cards that I did not anticipate.

To my mind, though, Dave Brat’s victory and Cantor’s defeat should be cause for celebration among people from across the ideological spectrum. Anyone who wants their elected leaders held accountable—and reminded that they work for the citizens—might count Tuesday’s primary as a win. As Jonathan Blank, a partner in the Charlottesville arm of McGuire Woods and a former local Democratic Party chairman, told me happily: “It is another signal to both parties that the politics of ‘no’ is unsustainable.” There is another message from this, though. Any citizen who works hard and cooperates with others can make a difference in our society, and even in our electoral history. A job I took on for less than a year — partly on a lark (even though I performed my duties seriously) — played a role in ousting the House majority leader. Wow.

Correction: Jonathan Blank’s title was misstated in an earlier version of this story. He is a partner in Charlottesville.  His quoted statement was personal, as a former local party chairman, and was not made in a professional capacity. The story has been corrected.