As Democrats seek to gain seats in the House and Senate, an old battle is being waged with new ferocity: To win elections, is it better to nominate full-throated leftists who will embrace Medicare-for-all, propose jobs guarantees and abolish Immigration and Customs Enforcement — or more-cautious moderates who can peel away center-right Republicans wary of President Trump and his “populist” views?

Political scientists have failed to reach a consensus on this fundamental question. On the one hand, aggregate studies of elections seem to indicate that more-moderate candidates tend to outperform more-extreme candidates. On the other, surveys of individual voters suggest that they tend to be poorly informed and highly partisan. That suggests, in turn, that inflaming partisan sentiment by nominating a more-extreme candidate might be a sounder approach than making an issues-based appeal to voters in the middle with a more-moderate candidate.

We think we have resolved the apparent contradiction in those competing theories. In an academic study of competitive U.S. House primaries from 2006 to 2014, we found that extremist nominees do considerably worse in the general election, on average, than moderates. The reason, however, may come as a surprise: It’s not that extremists turn off moderates in their own party. It’s that they fire up the other party’s base.

In other words, when Democrats nominate more-extreme candidates, they can expect more Republicans to show up to vote against their nominee in the general election.

We are not election prognosticators, and we don’t yet have the data to say whether either party has nominated more extremists than usual this year (though this Brookings Institution analysis seems to suggest that moderates are holding their own on the Democratic side). Every election has a different dynamic, and many factors — the economy, the turmoil of the Trump presidency, and the surge in the number of female candidates — will matter a great deal in November. (What’s more, Democrats in 2018 may decide they’d rather nominate more-extreme candidates even if they suffer an electoral penalty, if these nominations change their party’s platform in the long run; something similar happened on the Republican side during the tea party revolution.)

Still, our research suggests that the case for nominating ideologically “pure,” base-rallying candidates as an explicit strategy to win elections should be viewed with some skepticism.

To arrive at this conclusion, we first measured the ideological positions of House primary candidates in elections between 2006 and 2014, using the sources of their campaign contributions to gauge ideology. If most of a candidate’s donations came from donors who tend to support far-left incumbents, we inferred that he or she is likely to be a far-left candidate — and vice versa for far-right candidates. We then compared cases where more-extreme candidates win extremely close, “coin-flip” primaries over more-moderate candidates with cases in which moderate candidates won similar squeakers.

These close elections produce a “natural experiment” in which the more-moderate or more-extreme candidate has essentially been chosen randomly, not unlike a drug trial in which people with similar symptoms are randomly assigned different treatments. We found that more-extreme nominees tend to win a substantially lower average of vote shares in the general election, tend to win the general election less often, and tend to increase turnout among voters in the opposing party.

In addition to their strategic implications, our findings speak to the broader debate over identity-based politics (including party identity) and hyper-partisanship. Many have pointed to the supposedly “tribal” way in which individuals process political information as proof that moderate candidates do not perform better in U.S. elections. In the recent book “Democracy for Realists,” for example, the political scientists Christopher Achen and Larry Bartels write that “election outcomes are essentially random choices among the available parties.” Voters, they argue, largely side with their party, but are buffeted by tides in sentiment and by campaigns that “activate” certain identities in the electorate, regardless of whether candidates hold more-moderate or more-extreme views.

Our study shows why this logic is incomplete: Even if voters are highly partisan and never vote on the basis of policy positions — a hypothesis that remains hotly contested — more-moderate candidates can still do better because more-extreme candidates spur a greater number of partisans on the other side to oppose them.

If moderates have an advantage in House elections, why is the U.S. House so polarized? One of us (Andrew Hall) has found that moderate citizens are reluctant to run for political office because of the difficulties of running for, and then holding, such positions have increased over time (as explained in the forthcoming book “Who Wants to Run? How the Devaluing of Political Office Drives Polarization"). The demands of raising funds and the scrutiny of tabloid political coverage have risen at the same time that opportunities to make policy and forge rewarding political careers in the legislature have fallen. As moderates self-select out of the process, the group of people running for the House has drifted toward extremists over time. That leaves voters in many cases with no choice but to elect more-extreme candidates from both parties.

The debate isn’t going away. Slate’s Jamelle Bouie recently offered the case against moderation: “Modern elections don’t turn on capturing a mythical ‘center,’ they turn on activating, expanding, and mobilizing your base and demoralizing the opposition.” And the Economist summarized the pro-moderate case: “Some activists say the party needs to learn from Bill Clinton.”

There are exceptions to every rule, and political conditions can shift over time. But the evidence suggests that if parties want the best chance to win elections, they should keep in mind that extremist nominees tend to perform worse, electorally, in large part because they spur the opposing party’s base to turn out and vote.