John Boehner’s tenure as speaker of the House, which will end with his resignation next month, is striking because of a seeming contradiction. By statistical measures, it featured an extraordinary degree of party unity among Republicans in the House. At almost no point in history have such a large majority of Republicans voted together so often, especially when they stood in opposition to Democrats.

And yet, Boehner was brought down by division within the Republican ranks: His decision to resign was motivated by a group of dissident, highly conservative Republicans, the Freedom Caucus, who had threatened a no-confidence vote in his speakership. Meanwhile, Republicans have had trouble reaching consensus in many other respects during Boehner’s years as speaker: most notably, in choosing a candidate in the current presidential race.

So are Republicans a party united or divided? To a historic degree they are both. They are united against Democrats and deeply divided as a group.

The rest of this article will rely on data from Voteview.com, a website published by political scientists Keith Poole, Howard Rosenthal and Christopher Hare. Voteview tracks roll call voting in Congress and publishes statistics such as DW-Nominate, an algorithm that rates members of Congress on a liberal-conservative scale. One Voteview statistic is called the Party Unity Score, which measures the unanimity of voting within one party when it stands in opposition to the other party. In the 113th Congress, which served under Boehner from January 2013 to January 2015, Republicans had a Party Unity Score of 94.6 percent, the highest ever for the GOP.

Revealingly, however, Republicans were more united when voting against Democrats than when voting with them. On issues where Republicans voted in the opposite direction from Democrats, the GOP had a Party Unity Score of 94.6 percent, as I mentioned. But when the parties took the same side on a vote, fewer Republicans — 90.4 percent — joined the GOP majority. Put another way, Boehner had an easier time getting Republicans to agree with one another when they disagreed with Democrats. This might seem obvious, given the hyperpartisan politics of Congress today, but by this statistical measure it’s fairly unusual historically.

It also helps to explain the dynamics of the last couple of congresses. The 112th and 113th Congresses were among the least productive ever as measured by the number of bills passed into law. But that doesn’t mean Boehner left the House to twiddle its thumbs. Instead, he scheduled a lot of votes: The 112th Congress took about 1,600 roll call votes and the 113th took about 1,200, according to Voteview’s data, high figures by historical standards.

Many of those votes were like the dozens that Boehner scheduled to defund Obamacare or Planned Parenthood. The legislation under consideration had no chance to become law so long as Democrats controlled the presidency (and, until this year, the Senate). It’s not that these votes served no purpose, however. Instead, they may have been more like bonding rituals — a way for Boehner and congressional Republicans to reassert their partisan loyalty, both to one another and to the donor base at home.

Republicans may have needed a few of those feel-good moments because, as we’ve seen in the presidential race, there are quite a few ideological divisions within the party. We at FiveThirtyEight usually prefer to think of these divisions as existing along multiple dimensions — for instance, there can be some Republicans who are moderate on social policy but conservative on fiscal policy, or vice versa. But they also show up in DW-Nominate, an algorithm that tries to explain as much congressional voting behavior as it can along a single, left-right axis.

GOP lawmakers have steadily become more conservative, according to the system. DW-Nominate scores run on a scale from roughly -1 (extremely liberal) to +1 (extremely conservative), where 0 represents a centrist, and the median House Republican in the 92nd Congress, which served from 1971 to 1973 under President Richard Nixon, had a DW-Nominate score of +0.193, only very slightly to the right of center. By the 113th Congress, the median score had increased to +0.732, which is extremely conservative. The most conservative Republicans in the House 25 or 30 years ago would be among the most liberal members now, says DW-Nominate.

But, while there are few truly moderate Republicans left in Congress, there are meaningful differences between highly conservative, anti-establishment groups like the Freedom Caucus and pro-establishment, mainline conservative groups like the Main Street Partnership. In fact, according to DW-Nominate, these differences have expanded over time. In the 113th Congress, the gap in DW-Nominate scores between the most conservative flank of the GOP and the most moderate flank was the highest ever for the modern Republican Party:

When Republicans stand in opposition to Democrats, these differences don’t matter all that much. According to DW-Nominate, the most liberal Republicans in Congress are now to the right of the most conservative Democrats. But when the Republican Party is working on its own, choosing strategies, legislative priorities and candidates for office, they can reveal considerable dissent within the party. Should Republicans win the White House next year, they’ll probably have unified control of government. That might prove trickier for Republicans to manage than you might think, and now they’ll have to do it without Boehner at the helm.

Read more:

The Hard-Line Republicans Who Pushed John Boehner Out

John Boehner Had A Good Run