Barack Obama wanted to be the Democrats’ Ronald Reagan. Instead, he is leaving office more like the Democrats’ Jerry Ford: personally popular but with his party defeated, divided, and in despair. Democrats on Obama’s watch have, like Republicans after Ford, dropped to historically low numbers of congressmen, governors, and state legislators. The Democratic party today has less direct influence on American government at all levels than at any time since Reconstruction. On the surface, that looks like a pretty awful political legacy.

But recall that Reagan and Republican renewal came just four years after Ford’s 1976 defeat. The seeds for that renewal were present for all who had eyes to see. Those seeds, coupled with an inexperienced Democratic president who could not meet the demands of his office and a series of economic and international crises that would have tested even the most skilled statesman, did not take long to bear fruit.

Obama planted a number of political seeds during his tenure, seeds that could, in the hands of a skilled gardener, blossom quite quickly if Donald Trump and the Republican Congress don’t govern wisely. If Obama’s strategy played poorly in the short run, we cannot yet count out the possibility that it will play out quite well over the coming years.

First, though, let us recount his political shortcomings. The president’s smug arrogance did not simply drive Republicans crazy, it led him to push on in pursuit of a progressive paradise when wiser Democrats were counselling caution. Obama had campaigned as a healer, a person who could mix red and blue in pursuit of a common American vision. When he instead governed as a progressive (albeit as one never pure enough for the faithful), pushing climate change and Obamacare as his major priorities, he broke faith with the independents and moderate blue-collar Democrats who had elected him and given Democrats the largest House and Senate majorities they had possessed since before Ronald Reagan.

These were simply unwise priorities to push when the nation was wracked with a massive, worsening recession. But that did not matter to the 47-year-old who had already authored two autobiographies. According to the New York Times, Obama’s first treasury secretary, Timothy Geithner, told him early on that his legacy would be preventing a second great depression. Obama replied, “That’s not good enough for me.” That, plus encouraging a fast recovery, would have been plenty good for most Americans.

Obama’s progressive advisers, ignoring the counsel of his first chief of staff, Rahm Emmanuel, believed the reason Bill Clinton’s Democrats had been wiped out in 1994—after they had sought to pass a progressive wish list—was that they had flinched and not rammed their priorities through Congress. Do that, they told Obama, and Americans will reward the bold. Instead, Democrats lost even more seats in the House in 2010 than they had in 1994, dropping to their lowest level since 1946.

Devastation dogged down-ballot Democrats, too. Republicans picked up five governorships, winning in the large states of Wisconsin, Michigan, Ohio, Pennsylvania, and Florida. They gained an incredible 720 state legislative seats, picking up majority control in 21 legislative chambers. These gains allowed the GOP to control redistricting in each of the states listed above, as well as other important states they already controlled, such as Texas. This in turn allowed Republicans to dominate the redistricting process for the first time in decades, redrawing congressional and state legislative lines heavily in their favor.

Bill Clinton learned from his early mistakes and tacked to the center for the remainder of his presidency. Obama never did. He continued to push progressive priorities instead of those championed by the broad center of America, relying on the power of the executive to move them forward when the Republican-controlled House wouldn’t act. So, add stubbornness to arrogance as a second compounding feature of Obama’s political legacy.

Obama did win reelection in 2012, but that was because of Republican failure as much as his own genius. The Republican party thought it didn’t need to offer an attractive alternative vision to reach the disaffected center. It nominated in Mitt Romney a man who would have made a great scoutmaster but who developed no agenda that could make up for his bland, MBA-as-savior political persona. And so Republicans failed to win the White House or take control of the Senate in what they had thought would be an easy victory, given the seats up for grabs.

But Obama seems to think that he, not the Dos Equis guy, is the most interesting man in the world, and so he followed up his narrow escape with a second dose of stubbornness in pursuit of progressive ideals. The Paris climate accords, the Iran deal, the executive orders on immigration—all seemed wildly out of sorts with the priorities and policies preferred by the independents and blue-collar voters who had just reelected him. They therefore delivered another Democratic drubbing in 2014.

Trump’s nomination gave Democrats a golden opportunity to move beyond Obama. The Donald might indeed be the most interesting man in America, but throughout 2016 he was certainly among the least popular. As Hillary moved to the left to attract progressives, she doubled down on the policy priorities middle America didn’t value. Middle America had been screaming “What part of ‘no’ don’t you understand?” to Democrats for eight years. They didn’t listen, and so we are where we are.

Obama may look the fool now; he might, however, look the genius in the not-so-distant future. That’s because the very policies and priorities that don’t attract the current American center are quite popular with the future American voter.

Many young, college-educated whites want a form of secular multiculturalism. Many first-generation Latinos want friendly immigration policies and expanding government. These voters are poised to make up an ever-growing share of the electorate.

We should not forget that Clinton won the popular vote and only barely lost the three midwestern states that gave Trump the presidency. She also lost Florida and North Carolina by close margins and reduced the GOP’s winning margin in Arizona by almost two-thirds. Had she shown even the slightest interest in moving to the middle, Hillary Clinton would be president and the Democrats would control the Senate.

Other, wiser Democrats have run campaigns that appeal to the center and the Left, and they have won in key swing states. There is no reason a Democratic Reagan can’t see this and make the small but necessary adjustments to regain the White House.

Obama’s great success as a politician has been to build a very large and very loyal Democratic constituency. Even in his darkest hours, Obama’s popularity ratings never dropped below 40 percent, usually hovering in the low to mid 40s even when he was down. The Democrats’ progressivism may give them a low ceiling, but it also seems to give them a very high floor.

The Republicans would be wrong to think that their hold on the House or the states is impregnable. The GOP has nine governorships up for election in 2017 or 2018 in states that voted for Hillary Clinton and that Obama won twice. It holds another five up for election in those years in Obama/Trump states. It wouldn’t take much for Democrats to make a huge rebound in statehouses, and every governor elected in those years will be able to block Republican redistricting efforts in 2021.

Gerrymandering is a big reason Republicans hold large majorities in many statehouses, and is a significant reason they have a House majority. Fairer redistricting plans in states such as Florida, Pennsylvania, Ohio, and Michigan could cost the GOP as many as 15 House seats. A court challenge to the Republican gerrymander of Wisconsin is already on its way to the U.S. Supreme Court. Justice Anthony Kennedy previously suggested that partisan gerrymanders can violate the Constitution. If he joins with the Court’s liberals in judging that Wisconsin’s plan does so, and if the majority were to adopt legal standards to constrain future redistricting, then the GOP’s House and state legislative majorities would no longer be secure.

The Obama political legacy, therefore, remains a work in progress. Moving the Democratic party to the left has given the Republicans a chance to come back. Only eight years ago, they were defeated, divided, and in despair. Obama gave them something to unite behind and the massive win in 2010 gave them hope. But a party that controls all the levers of government can no longer unite by being against something. It can only unite by being for something—and that remains a challenge for the GOP.

Republicans must do what Obama and Hillary Clinton failed to do: Find a way to unite the concerns of their base with those of the center. That will require what neither Democrat was willing to do, be creative and compromise. Trump’s core voters, in particular, believe they have been given a raw deal by both parties for a very long time. They flocked to him precisely because he seemed to be free of both parties’ bases and their tribal concerns. Republicans’ failure to recognize this would set the stage for conflict with the White House and defeat in 2018.

To avoid such an outcome, Republicans need to learn the difference between principle and ideology. Fortunately, they had a great teacher in Ronald Reagan.

Reagan’s 1977 speech “The New Republican Party” asserts that this difference provides the secret to winning. Americans hate ideology, which Reagan defined as the “slavish adherence to abstraction.” Ideologues, Reagan said, make the facts fit their preconceived theories. Conservatives derive their ideals from facts—and adjust their policies when they see new facts.

As president, Reagan did exactly that. He was for free trade but levied penalties on Japan many times because of what he saw as unfair trading practices. He was against tax increases, but he signed off on two tax hikes during his tenure, including one designed to keep Social Security solvent for decades. He hated the Soviet Union but was willing to sign an arms-control agreement with Mikhail Gorbachev when he came to believe Gorbachev was a different type of Soviet leader.

In his speech, Reagan specifically criticized ideological fanatics, people who “sacrifice principle to theory, worship only the god of political, social, and economic abstractions, ignoring the realities of everyday life. They are not conservatives.” Barack Obama and Hillary Clinton were rightly judged by the American people to be ideologues, people who cared more about their abstractions than about everyday life. Smug, arrogant, and stubborn are no ways to go through political life. Republicans who want to make Obama’s political legacy an unambiguously negative one should listen to Reagan.

Mr. Olsen is a senior fellow at the Ethics and Public Policy Center and an adjunct professor at Villanova University. He is the author of the forthcoming book Ronald Reagan: New Deal Republican.