Barack Obama has been elected president twice, but his party has now gotten drubbed in the two midterm elections held during his presidency. He will face a Republican Senate and House. Because the Democrats will be able to block Republican initiatives in the Senate with forty votes, and because, if necessary, Obama can exercise a veto, he can prevent the evisceration of the Affordable Care Act and the Dodd-Frank financial reform bill, but he and the Democrats won’t be able to pass any initiatives of their own; and he will have a very difficult time getting his nominations and appointments confirmed. Gridlock? That’s probably too mild a description of what America has in store over the next two years.

Did it have to happen—particularly given that in repudiating the president and the Democrats, voters were reacting to the palsied state of Washington politics? A president’s party rarely does well in midterm elections, and that’s been particularly true in a president’s second term. And the country has still not fully recovered from the Great Recession. Employment is up, but not wages, and that may have hurt the Democrats. But midterm losses don’t have to be as severe as those that the Democrats have suffered under Obama. In 1998, resident Clinton and the Democrats actually added five seats in the House, broke even in the Senate, and won a governorship. Obama himself has to take some blame and his Republican opponents some credit for what happened yesterday.

Here are the key factors that contributed to this year’s Democratic debacle. 

The Midterm Factor

In midterm elections, turnout is generally far lower than in presidential years. In 2010 and 2014, some of those groups of voters that had helped Obama and the Democrats win in 2008 and 2012 turned out in disproportionately smaller numbers that those voters who had supported Republicans in 2008 and 2012. Take younger voters. In 2012, voters between 18 and 29 years old made up 19 percent of the electorate and voted for Obama by 60 to 37 percent. Voters from 30 to 44 years old made up 27 percent and backed Obama 52 to 45. That’s almost half the electorate. In the preliminary exit polls yesterday (the exit polls are adjustment to reflect the final results), these voters made up only 32 percent of the electorate. The 18- to 29-year-olds backed Democrats by 55 to 42 percent and the 30- to 44-year-olds backed Democrats by 52 to 46 percent.

Now look at the flipside. Voters 45-to-64 and 65 and over went for Mitt Romney in 2012 and for Republicans this year. They made up 54 percent of the electorate in 2012 but a whopping 67 percent on Tuesday. If the proportions of the vote had been similar to those of presidential years, the Democrats might have had a better chance in the elections. Take the North Carolina race, where Thom Tillis defeated incumbent Democratic Senator Kay Hagan. According to the exit polls, Hagan won 18- to 29-year-olds 54 to 39 percent and 30- to 44-year-olds 56 to 39 percent and lost 45- to 64-year-olds 48 to 50 percent and 65 and over 44 to 54 percent. But the 18- to 44-year-olds only made up 36 percent of the vote. Democrats faced a similar problem with the Hispanic vote, which was important in Florida and Colorado. But turnout wasn’t the only problem the Democrats faced.

The Obama Factor

The Republican candidates this year tied their opponents to Obama and to his policies, and the tactic worked. Public disapproval of Obama’s presidency, which has remained high, rubbed off on Democratic candidates. In a Pew poll taken in mid-October, 32 percent of voters said that they considered their vote for Congress as a vote against Barack Obama; 20 percent thought of it as a vote for Obama. These figures are usually understated—people don’t like to say their vote for one individual is based on their feelings about another. The significance of the 12-point margin and of a third of the electorate saying that their vote was directed against the president becomes clear when one compares 2014 with 2010. In that year, 28 percent said they were voting against Obama and 26 percent for. In 1994, another big Republican midterm victory, only 21 percent of the electorate said they were voting against Clinton. The only midterm election where the vote was similarly directed against the president was 2006, when Americans cast a vote against George W. Bush. Like that election, this one was a referendum on the president.

Could Obama and the Democrats have avoided the voters’ wrath? I think there was an opportunity to do so in the fall of 2013 when many Americans blamed the Republicans for the shutdown of the government. In a Wall Street Journal/NBC News poll from October 7-9, 2013, Obama’s approval rate was 47 percent and his disapproval rate 48 percent, and registered voters said by 47 to 39 percent that they would prefer that Democrats control the next Congress. By the next poll on December 13, Obama’s approval was at 43 percent and his disapproval at 54 percent and voters now preferred a Republican congress by 44 to 42 percent. A Washington Post poll registered the same trends. The bottom fell out of Obama’s approval and of Democrat prospects for November 2014 sometime in mid-October 2013. What happened during October was the administration’s failed rollout of the Affordable Care Act. That was Obama’s Katrina, and it turned out to be the Democrats’ as well. Of course, the administration subsequently repaired the program, but the political damage was lasting. It occurred at just that time when the issues of the coming election were being defined. Obama’s and the Democrats’ popularity never recovered.

Obama didn’t help matters in the year to come. While he has brought his substantial political skills to bear on his presidential campaigns, he has remained detached from the midterm elections in 2010 and 2014, insisting last month that his policies would speak for themselves. But by withdrawing from the struggle—and not attempting to frame the 2010 or 2014 elections—Obama allowed voters to blame him and the Democrats for whatever continues to ail America. And the Republicans did a good job in this election of turning the voters’ attention on Obama and away from their own lack of a program for the country.

The Republican Factor

In 2010 and again in 2012, the Republicans squandered their chances in Senate races by nominating far-right candidates like Richard Mourdock and Christine O’Donnell who proved unpalatable even to some Republican voters. After the Tea Party-led shutdown in the fall of 2013, the Republican leadership kept their troops in line. There were no more shutdowns. Republican business groups and organizations like Karl Rove’s Crossroads also made an effort to nominate candidates who could move to the center. And most of the candidates attempted to smooth off their rough edges.

Colorado Republican Cory Gardner, who took Mark Udall's Senate seat, repudiated his support for “personhood” bills that would have banned contraception and even came out for over-the-counter contraception. Wisconsin Governor Scott Walker ran an ad backing equal pay for women after previously signing a bill that repealed a state law requiring equal pay. A host of Republican candidates, including Bruce Rauner in Illinois, Tom Cotton in Arkansas, and Dan Sullivan in Alaska, suddenly decided they supported an increase in the minimum wage. North Carolina Senate candidate Thom Tillis decided he supported expanding Medicaid in his state. By moving to the center, the Republicans neutralized Democratic efforts to paint them as extremists.

The Silver Lining

If there is a silver lining in the awful results of this year’s election, it lies in the fact that if the turnout had been similar to 2012 or 2008, the Democrats would have done much better. As The New York Times' Nate Cohn has argued, that could bode well for 2016, which is not only a presidential year, but a year when the Republicans’ vulnerable Senate class of 2010 will come up for re-election. If you look at how the different groups voted, the Democrats preserved their edge among younger voters, African Americans (whose turnout seems to have been pretty good), Hispanics, single women, and professionals. Almost all the Democratic candidates did well, for instance, among voters with post-graduate degrees. In Georgia, Michelle Nunn won these voters by 53 to 46 percent. So that’s a consolation of sorts.

But in 2016 and in future midterm elections, the Democrats will still have to do better among those parts of the electorate that have flocked to the Republicans: older voters and white working-class voters. The numbers for the latter in this election were singularly dispiriting. In Florida, Democratic gubernatorial candidate Charlie Crist lost whites without college degrees by 32 to 61 percent; in Virginia, Senator Mark Warner’s near-death experience was due to losing these voters by 30 to 68 percent. In Colorado and Iowa, they held the key to Republican Senate victories. In 2012, the Democrats benefited by facing a Republican who reeked of money and privilege and displayed indifference toward the 47 percent. Romney lost the white working class in states like Ohio. Democrats may not have that luxury of a Mitt Romney in the next election. And in that case, they will have to do considerably better among these voters, or else 2016 could turn out to be another nightmare election for the Democrats.