FILE - In this Aug. 23, 2008, file photo, then-Democratic presidential candidate Sen. Barack Obama D-Ill., appears at a campaign stop in Springfield, Ill. He was a first-term senator-turned-president. A former law professor with little experience in economics or management. When he walked into the White House he had one, clear job: Piece together the shards of a shattered U.S. economy. It wasn’t smooth and it wasn’t fast, but Obama ultimately succeeded. Obama will leave behind an economy far stronger than the one he inherited by most measures. (AP Photo/M. Spencer Green, File)

FILE - In this Feb. 17, 2009, file photo, Vice President Joe Biden watches as President Barack Obama signs the American Recovery and Reinvestment Act during a ceremony at the Denver Museum of Nature and Science in Denver. He was a first-term senator-turned-president. A former law professor with little experience in economics or management. When he walked into the White House he had one, clear job: Piece together the shards of a shattered U.S. economy. It wasn’t smooth and it wasn’t fast, but Obama ultimately succeeded. Obama will leave behind an economy far stronger than the one he inherited by most measures. (AP Photo/Gerald Herbert, File)

FILE - In this May 6, 2016, file photo, President Barack Obama speaks in the White House briefing room in Washington. He was a first-term senator-turned-president. A former law professor with little experience in economics or management. When he walked into the White House he had one, clear job: Piece together the shards of a shattered U.S. economy. It wasn’t smooth and it wasn’t fast, but Obama ultimately succeeded. Obama will leave behind an economy far stronger than the one he inherited by most measures. (AP Photo/Carolyn Kaster, File)

FILE - In this Feb. 12, 2009, file photo, President Barack Obama puts his hand to his heart during the Pledge of Allegiance at the 102nd Abraham Lincoln Association banquet in Springfield, Ill. He was a first-term senator-turned-president. A former law professor with little experience in economics or management. When he walked into the White House he had one, clear job: Piece together the shards of a shattered U.S. economy. It wasn’t smooth and it wasn’t fast, but Obama ultimately succeeded. Obama will leave behind an economy far stronger than the one he inherited by most measures. (AP Photo/Charles Dharapak, File)

Washington — He was a first-term senator-turned-president, a former law professor with little experience in economics or management. When he entered the White House he had one essential task: piece together the shards of a shattered U.S. economy.

It wasn’t smooth and it wasn’t fast. But President Obama will leave behind, by most measures, an economy far stronger than the one he inherited.

Unemployment is 4.6 percent, a nine-year low. Stocks keep setting highs. An additional 20 million Americans have health insurance coverage. The nation has shifted toward cleaner energy sources: natural gas, wind and solar.

Yet it’s also an economy that left many people feeling neglected. Polling after the November election found that nearly two-thirds of voters described the economy as “not so good” or “poor.”

The costs of housing, college and prescription drugs kept outpacing paychecks. Job options had been dwindling for workers with only high school diplomas even before Obama took office, but the downturn and slow recovery magnified the pain of that trend. Many people gave up looking for work. Struggling rural towns never enjoyed the uplift that benefited major cities

Fueled in part by such challenges, voters chose to pass the presidency to Donald Trump, a Republican who had railed against a weak economy and promised to undo many of Obama’s policies.

The gap between the economy’s overall health and Americans’ lingering anxieties cuts to the heart of Obama’s legacy. The president and his team took historic actions to pull the economy back from the brink. But those very steps failed to help swaths of America and turned many people against his policies, setting the stage for Trump’s nationalist platform.

“We saved the economy from a failing financial system, though we lost the country doing it,” Obama’s first treasury secretary, Tim Geithner, concluded in his 2014 memoirs.

Economic problems that had been simmering for decades started to boil with the Great Recession of 2007-2009. It suddenly became Obama’s responsibility to address problems that were both immediate and generations in the making.

Building on measures taken by George W. Bush’s administration, Obama pumped $412 billion into teetering banks, troubled financial firms and the struggling automakers General Motors and Chrysler. The infusion was stigmatized for being a government bailout, though the money was ultimately repaid.

Then there was the Recovery Act, known as the “stimulus,” enacted less than a month after Obama took the oath of office in 2009. Administration estimates initially suggested that the $836 billion stimulus — a mix of tax cuts, public investments and direct aid — would prevent unemployment from rising above 8 percent.

Those projections were faulty, based on economic figures that were later downgraded. The 8 percent unemployment projection ultimately became a political albatross as the rate peaked at 10 percent that October — proof to some Republicans that the stimulus had failed.

But there’s little doubt the bill made an impact. The U.S. recovery was, and continues to be, stronger than in economies in Europe and Japan.

Administration officials note that until the full force of the stimulus arrived, key U.S. economic measures were on the same trajectory as in the Great Depression.

Even more polarizing was the 2010 Patient Protection and Affordable Care Act, a major extension of the federal social safety net. It expanded Medicaid while imposing new regulations designed to support the middle class that allowed young adults to stay on parents’ plans and created marketplaces for purchasing health insurance.

Just 8.9 percent of Americans now lack health insurance — a historic low, according to the National Center for Health Statistics. But critics complain that Obama’s health care law brought bureaucratic headaches and burdensome costs. The average premium for plans under the health care law next year jumped 22 percent, an increase that will be offset somewhat by federal subsidies.

The combination of all these acts fueled a conservative backlash that would propel dozens of Republicans into Congress, costing Democrats control of the House in 2010 and bringing Obama’s economic agenda to a halt.

The following years would be defined by deficit battles, budget cuts, standoffs over the debt and a compromise on tax cuts. The Obama team’s efforts to boost growth through additional infrastructure spending and immigration reform were quashed by House Republicans.

Throughout it all, while Americans became disillusioned by the bickering in Washington, Obama’s economy slowly crept back.

Yet the recovery remains uneven, so much so that Obama never took a full victory lap. The president has routinely followed his remarks about the healing economy with the caveat that more progress was needed.

“Historians will remember President Obama for his rational, evidence-based approach,” said Alan Krueger, a former economic adviser, “as opposed to the emotional, visceral style of the two presidents who will bookend his time in office.”

“A lesser president,” Krueger added, would have “upended our economic system for short-term political gain.”

Obama often spoke with restraint and governed through policy, rather than whipping up public outrage against firms linked to the financial crisis. His administration preserved private contracts, even though those contracts rewarded huge bonuses to some of the bankers the government helped rescue.

While voters returned Obama to the White House in 2012, there was a nagging sense of a system rigged against them — a frustration that Trump tapped effectively.

The Republican businessman barnstormed through rural white America, talking at a gut level to supporters whose communities felt left behind by the recovery. He promises to return manufacturing and mining jobs that most economists believe are long lost.

Trump challenged the accuracy of the unemployment rate, since many Americans gave up searching for jobs and were no longer counted as unemployed. He has promised major spending on infrastructure and tax cuts. He says he plans to eliminate regulations and repeal and replace Obama’s health care law.

“Trump’s victory is very harmful to his legacy — Obama understood that,” said Stephen Moore, a fellow at the conservative Heritage Foundation who advised the Trump campaign. “It’s why he campaigned so hard for Hillary Clinton.”

The White House acknowledges the disconnect between the economy’s health and the public’s beliefs about what the president achieved. But Jason Furman, chairman of Obama’s Council of Economic Advisers, contended that voter pessimism about the economy is mostly about politics.

He noted that consumer spending has helped support economic growth, a sign that Americans “are not behaving in a way that is consistent with massive amounts of anxiety about the future and uncertainty about whether they’ll keep their jobs.”

“People have a big political prism that they use in interpreting economic information,” Furman said.