But since Donald J. Trump, who promised to repeal the law, was elected president, that long-held pattern has begun to shift. In a variety of recent polls, with questions asked in different ways, more Americans are now saying they favor Obamacare than oppose it.

The NBC News/Wall Street Journal poll has been tracking views of the health law since 2009. Its poll in January indicated for the first time that more people viewed the health law as a good idea than as a bad one.

An NBC/WSJ poll asked whether Barack Obama’s health care plan was a good or bad idea

50% Good idea: 45% 40 Bad idea: 41% 30 20 10 2009 2010 2011 2012 2013 2014 2015 2016 2017 50% Good idea: 45% 40 Bad idea: 41% 30 20 10 2009 2010 2011 2012 2013 2014 2015 2016 2017 50% Good idea: 45% 40 Bad idea: 41% 30 20 10 2009 2010 2011 2012 2013 2014 2015 2016 2017 Source: A NBC News/Wall Street Journal survey conducted Jan. 12-15 asked 1,000 adults whether Barack Obama’s health care plan was a good idea or a bad idea.

A Fox News poll showed a similar flip in views after the election. Its survey found that half of Americans now view the law favorably.

A Fox News poll has tracked voters’ opinions of the law

Favorable Unfavorable Jan. 2017 50% 46 Aug. 2015 41% 54 March 2015 38% 58 Unfavorable Favorable Jan. 2017 50% 46 Aug. 2015 41% 54 March 2015 38% 58 Favorable Unfavorable Jan. 2017 50% 46 Aug. 2015 41% 54 March 2015 38% 58 Source: A Fox News poll conducted by telephone Jan. 15-18, 2017 asked 1,006 registered voters whether they had a favorable or unfavorable opinion of the 2010 health care law, also known as Obamacare.

The change almost certainly hasn’t come because the health care law is performing better. Competition in many markets has declined, and insurance prices for 2017 Obamacare plans rose sharply.

What’s changed is that the prospect of Obamacare’s repeal has become much more real. Mr. Trump identified it as a top domestic policy priority, and Congress rapidly passed a budget bill laying the groundwork for a broader repeal.

“There is a shifting public focus away from what is wrong with the Affordable Care Act to a world where 21 million people could lose coverage,” said Robert Blendon, a professor of health policy and political analysis at Harvard, in an email. “The Affordable Care Act may not be more popular, but the implications of repeal are shifting people to a less negative stand on the law.”

Mr. Blendon said that once Republicans proposed a detailed replacement for the law, public opinion could shift again.

Morning Consult polls taken before and after Mr. Trump’s inauguration show approval of Obamacare has increased the most among urban voters, Hispanic voters and people who say the country is on the “wrong track.”

Morning Consult polls tracked the change in favorability of the law before and after Mr. Trump’s inauguration among voters who ...

+2 pts. +6 +10 +12 Are Hispanic Said the country is on the wrong track Earn $50,000-$100,000 Live in urban areas Are ages 18-24 Live in the West Are ages 45-54 Are Democratic Earn $100,000+ Are ages 30-44 Are ages 55-64 Have no college degree Live in the Northeast Are registered to vote Are conservative Are white +2 pts. +6 +10 +12 Are Hispanic Said the country is on the wrong track Earn $50,000-$100,000 Live in urban areas Are ages 18-24 Live in the West Are ages 45-54 Are Democratic Earn $100,000+ Are ages 30-44 Are ages 55-64 Have no college degree Live in the Northeast Are registered to vote Are conservative Are white +2 pts. +6 +10 +12 Are Hispanic Said the country is on the wrong track Earn $50,000-$100,000 Live in urban areas Are ages 18-24 Live in the West Are ages 45-54 Are Democratic Earn $100,000+ Are ages 30-44 Are ages 55-64 Have no college degree Live in the Northeast Are registered to vote Are conservative Are white Sources: A comparison of answers given in two Morning Consult polls. A poll on Jan. 20-22 asked 1,992 registered voters whether they approved or disapproved of the 2010 Affordable Care Act, sometimes referred to as Obamacare. The same question was asked of 1,988 registered voters on Jan. 5-7.

Support for the law has grown across many subgroups, but the largest movements appear to be in Democratic-leaning groups. Those people may not have loved Obamacare, but they worry more about its repeal.

The Pew Research Center has found that, for the first time since 2007, a majority of Americans believe it should be the federal government’s responsibility to make sure Americans have health insurance.

Pew found a big shift among low-income Republican voters, a key Trump constituency and a group that has benefitted substantially from the health law.

A Pew Research Center survey asked whether the federal government should make sure all Americans have health care coverage.

75% Yes: 60% 60 45 30 No: 38% 15 2000 2005 2010 2014 2017 75% Yes: 60% 60 45 30 No: 38% 15 2000 2005 2010 2014 2017 75% Yes: 60% 60 45 30 No: 38% 15 2000 2005 2010 2014 2017 Source: Pew Research Center survey asked 1,502 adults on Jan. 5-7 whether it is the responsibility of the federal government to make sure that all Americans have health care coverage. Data for 2000 to 2013 are from Gallup.