Public sentiment over Obamacare’s individual mandate, which requires everyone to buy insurance, is divided, a new poll finds.

Nearly 40 percent of respondents in a poll from the left-leaning think tank Urban Institute want the mandate repealed, while another 29.6 percent think it should be kept. About 30 percent of respondents were undecided about its fate.

The poll results released Tuesday come as the Senate considers repealing the mandate as part of its tax reform legislation.

The mandate is one of the most controversial parts of Obamacare. It requires everyone to buy health insurance or pay a fine, with exemptions for low incomes and other hardships such as recently losing a job.

The poll found that most Republicans or leaning Republican, 65.5 percent, favor repeal. In a twist, only 44 percent of Democrats support keeping the mandate.

Among the groups most in favor of repealing the mandate, but still below 50 percent, are adults 50 to 64, men, adults with low and middle incomes, and people with some college education or less, the poll said.

“Among those supporting repeal, 40.5 percent report that their main reason is that people should not be required to have insurance if they don’t want to,” according to a statement.

Meanwhile, the main reason adults favor keeping the mandate is to spread the costs of the sick and healthy over an entire risk pool.

The mandate was created as an incentive for healthier and younger people to sign up for Obamacare, helping to offset high medical claims from sicker people who signed up.

However, the mandate hasn’t worked out as intended as premiums rose partly because of a sicker-than-expected enrolled population.

The mandate’s penalty for 2017 is $695 per person or 2 percent of gross income, whichever amount is higher.

The effect of repealing the mandate is being hotly debated.

The nonpartisan Congressional Budget Office recently estimated that repealing it would mean 13 million people would forego insurance over the next decade. Repeal also would save $338 billion over a decade, which Senate Republicans want to use to fund tax cuts.

However, a Standard & Poor's analysis last week estimated that only 3 to 5 million people would not get insurance and only about $60 billion would be saved.

The CBO is examining its methodology for how it estimates the impact of the mandate, with a decision expected in a few months.

The Urban Institute used data from nearly 9,500 nonelderly adults from a September survey. It did not list a margin of error.