Three years out, few bets in U.S. politics looked as sure as Hillary Clinton’s election to the presidency in 2016. Republicans had badly polluted their brand in the debt ceiling standoff. Their coalition seemed to have dwindled to an embittered band of older white Southern men.

But it’s never wise to predict the future by projecting forward from the present.

By spring 2014, the U.S. economy had been expanding for almost 60 months, the fifth-longest expansion in U.S. history, but also the weakest and most lop-sided. Through the expansion, poorer Americans failed to raise their consumption to pre-2007 levels, even as richer Americans bid stock prices to record highs.

Facing a bleak Christmas selling season, Wal-Mart began cutting orders to suppliers in the fall of 2013. The official retailer of Lower America cut its sales force by 10%. Target also reported strangely disappointing sales in 2013. Ultra-down-market retailer Dollar General reported better sales, but almost all of those results were driven by its decision to begin selling tobacco products in its stores.

All the oomph in the U.S. economy was delivered by the top 10% of households. And they were vulnerable to events in the financial market. When such an event struck in the early spring, the U.S. economy toppled back into recession. The tentative employment gains of the Obama years were abruptly wiped out, and congressional Democrats suddenly faced a very ugly scenario in the fall 2014 elections.

In a frantic effort to mobilize supporters, the Democrats abruptly veered toward more populist economics. Senator Elizabeth Warren began to demand not just fines on JP Morgan, but the actual breakup of too-big-to-fail financial institutions. Too little, too late: instead of the gains they’d been counting on in 2013, the Democrats lost 15 House seats and control of the Senate in November 2014.

That defeat galvanized something in progressive Democrats. In an effort to collect chits for 2016, Hillary Clinton had campaigned hard for fellow Democrats in 2014. Now Clinton was damaged— and the fundraising successes of her ally, Virginia Governor Terry McAuliffe, suddenly became a target of criticism rather than a source of gratitude. “I don’t think we can auction our party’s future to Terry McAuliffe’s rich friends,” Senator Warren told MSNBC’s Rachel Maddow three days after the election defeat.

In the painful aftermath of 2014, many Democrats were ready to hear that the party had been defeated because President Obama had been too cautious in his policies and too remote in his style. As Obamacare stumbled from implementation difficulty to implementation difficulty, they remembered that the program they really wanted was Medicare for all. They seethed at the way Obama had submitted to Republican demands that budget balancing take precedence over job creation. And whatever happened to the administration’s promises on climate change?

Democrats liked Hillary personally. But they could see that a Clinton nomination implied a course correction to the right from an administration they already condemned as too conservative. And so, even as the front-runner led the fundraising race through 2015, Iowa and New Hampshire were filling with volunteers canvassing for Elizabeth Warren and her message: “She’s in it to win it. I’m in it for you.”

History didn’t repeat itself, and Elizabeth Warren was no Barack Obama. Hillary Clinton finished off the Warren challenge in April. But Clinton had needed to pivot sharply left in order to secure her victory. Analysis of the 2014 vote showed that Democrats had been hurt by an abrupt drop in Latino turnout. Democrats decided they could afford no more delay on the immigration issue. President Obama listed immigration as agenda item number one in his 2015 State of the Union address, but Hillary Clinton went further. With her characteristic fierce energy, Clinton poured herself into the fight, chanting “Si, se puede” at rally after rally.

With the flaming wreck of Marco Rubio’s presidential hopes as a warning beacon, moderate favorite Governor Christie tried to triangulate the immigration issue. Ted Cruz determinedly took a position of all-out opposition. In an interview on Univision, he chatted in Spanish with host Jorge Ramos, then turned to English to deliver a stark message: “This is America. We obey the law. People who can’t deal with that don’t belong here.”

The government shutdown and debt ceiling fight of 2013 may have looked disastrous from a national political perspective. But the dustups nonetheless earned Cruz the best fundraising list on the Republican side. While Rand Paul hesitated whether to play an “inside” game of reassuring Republican donors or an “outside” game of insurgency, Cruz’s fundraising allowed him to bypass the choice altogether, shoulder aside Rand Paul as the conservative favorite, and proceed straight to the main event: the battle against Gov. Chris Christie.

The Clinton-Warren fight divided and weakened Democrats. Many pundits compared the contest to the Humphrey vs. Kennedy fight of 1968. But back in 1968, there was an obvious solution: a unity ticket (had the gunman’s bullet missed Kennedy, that is). Democrats in 2016 were not prepared however to field an all-female ticket. Clinton was the nominee; Warren went back to the Senate.

Ted Cruz, however, could offer the vice presidency to Chris Christie—and the Democrats’ post-2014 leftward veer frightened Republican donors enough that they pressed Christie to accept. Unlike Romney in 2012, Cruz’s conservative allegiance could not be questioned, freeing him to write the vaguest platform and conduct the most issue-free campaign of any Republican since George H.W. Bush in 1988. Cruz delivered half his convention speech in Spanish and used the other half to rededicate the party to “the compassion of conservatism,” a subtle variant of an old phrase that delighted convention delegates.

Clinton Democrats took for granted that Cruz was unelectable. They had not appreciated how badly the 2014 recession would hurt them. Disenchanted Latinos and young people stayed home. So did down-market white males, who seemed to react to Clinton with almost visceral dislike. In the presidential election of 2008, almost 58% of eligible voters had turned out, the highest level since the extension of the vote to 18-year-olds. In 2016, turnout dropped below 50% for the first time since 1996.

Republicans turned back the clock on the Obama election map. They recaptured Florida and Virginia, North Carolina and Nevada, Ohio and Iowa: moving back into the red column all the states won by George W. Bush in 2004. It was a desperately narrow victory, but it was enough.