Eric Cantor’s primary loss to Dave Brat on Tuesday was a surprise on a number of levels. For starters, it is a prime example of the unintended consequences of redistricting gone awry. Moreover, no sitting majority leader has lost a primary since the office was created in 1899. And incumbents rarely lose primaries, period.

Since 1968, only 130 representatives and 24 senators have lost primary contests, according to data compiled by Greg Giroux of Bloomberg. The data shows that primary losses peak in the years following congressional redistricting, when two incumbents can end up fighting for the same redrawn district.

In 1992, the greatest number of primary upsets occurred, with 20 incumbents losing their seats to primary challengers that year. Another big year for primary turnover came in 2012, with seven Democrats and seven Republicans losing their seats before the general election. So far this year, only two incumbents have lost primaries — Cantor of Virginia and Ralph Hall of Texas, both Republicans who were challenged from the right.

Historically, Democrats have been twice as likely to lose primaries as Republicans. Democrats have tended to be the more fractious of the two parties, so this makes sense.

In recent years, however, Democrats have been relatively unified while the GOP has dealt with internal divisions caused by the rise of the tea party. This has caused primary losses to even out between the parties. Since 2008, Democratic incumbents have lost 11 primary challenges, while Republicans have lost 16. All but two of those Republican losses were to tea party challenges from the right.

Election Lab: See our current forecast for every congressional race in 2014

Similarly, Democrats have been twice as likely to lose primary fights brought about by redistricting. This has held true even in recent years. Since 2008, nearly half of Democratic primary losses (five out of 11) have come from multiple incumbents fighting over the same redrawn district. But fewer than 20 percent of Republican primary losses (three out of 16) have been caused by redistricting.

This illustrates how successful Republicans have been at drawing Democratic seats out of existence. But Cantor’s loss underscores the dangers of overenthusiastic gerrymandering. Virginia Republicans tweaked the boundaries of Cantor’s district in 2010 to make it more conservative. This seemed like a great idea in 2012, when Cantor won his primary by a huge margin. But the unintended consequence was that the district became so conservative that it made Cantor vulnerable to a challenge from the right, even though, ideologically, he’s about as conservative as Minnesota GOP Rep. Michele Bachmann.