Almost 12 million Americans signed up for 2018 health coverage through marketplaces created by the Affordable Care Act, according to a new tally that indicates nationwide enrollment remained virtually unchanged from last year despite President Trump’s persistent attacks on the 2010 health law.

The new enrollment numbers — which include totals from California and other states that operate their own marketplaces, as well as states that rely on the federal HealthCare.gov marketplace — offer the most detailed picture to date of the insurance markets.

And they suggest surprising strength in many markets across the country, with consumers steadily signing up for health plans even as Trump and his Republican congressional allies derided the markets as crumbling and unaffordable.

“This shows that consumers really want and need coverage,” said Trish Riley, executive director of the National Academy for State Health Policy, which compiled the nationwide enrollment tally.

“These are stable markets and a stable program,” she said.

Florida, which uses HealthCare.gov, and California continue to lead all states with 1.7 million and 1.5 million enrollees, respectively.

The annual enrollment tally remains a relatively crude metric that doesn’t account for what kind of consumers are signing up for coverage. And the totals don’t include Americans who are buying health plans on their own rather than through the official marketplaces created by the healthcare law.

But total sign-ups have become an important barometer of the law, often called Obamacare.

And the numbers have been closely watched every year as politicians have debated whether to roll back the law.

In 2018, most of the 39 states that rely on the U.S. Department of Health and Human Services to operate their markets saw small decreases compared to 2017, the data show.

But in a marked contrast, two-thirds of the marketplaces run by states instead of the federal government saw increased enrollment between 2017 and 2018, including Connecticut and New York.

That in large part reflects extensive efforts in many of these states to market health coverage, lengthen enrollment periods and conduct aggressive outreach campaigns to attract younger, healthier consumers who are critical to insurance markets.

“We had the best open enrollment period we have ever had,” said Allison O’Toole, chief executive of Minnesota’s insurance marketplace, known as MNsure, which saw enrollment surge nearly 6% this year. Elected officials in Minnesota developed their own reinsurance system to help control premiums this year.

Even bigger enrollment increases were recorded in Washington state, which had 7.6% increase, and Rhode Island, which led all states with a 12.1% increase.

HealthSource RI director Zachary Sherman attributed the success to the state’s ability to manage its own market, craft marketing and work with insurers to control premiums.

California’s enrollment dipped slightly in 2018, falling 2.3%, but the state saw a significant increase in new consumers, which was an encouraging sign, said Peter Lee, head of Covered California, the state’s marketplace.

“Put simply, marketing matters,” Lee said.

That is reflected not only in enrollment totals, but also in the type of consumers that state marketplaces were able to attract.

California, for example, has consistently had a healthier mix of enrollees than markets in other states. That, in turn, has helped keep premiums in check compared to other states and has kept markets competitive, with multiple insurers selling plans in most parts of California.

While California and other states that operate their own marketplaces invested in marketing and outreach, the Trump administration took a number of steps that weakened enrollment.

The enrollment period on HealthCare.gov was half as long this fall as in previous years, and the Trump administration slashed funds for advertising and outreach. The president also often publicly referred to Obamacare as “dead” or “over.”

“Obamacare is finished. It’s dead. It’s gone,” Trump declared on the eve of the 2018 open enrollment period, which began Nov. 1.

Many of the federal moves were not helpful, said Heather Korbulic, executive director of Nevada Health Link, which is operated by the state but uses the federal HealthCare.gov website.

Korbulic credited the state’s Republican governor, Brian Sandoval, with helping to stabilize a shaky market even as insurers stopped selling plans in the state and threatened to leave consumers in some rural areas with no choice of plans. Nevada, in the end, saw a 2.2% increase in enrollment this year.

In neighboring Arizona, which also has experienced significant turmoil in its insurance market, enrollment fell 15.6% in 2018, one of the largest drop-offs in the country. Arizona relied on the federal government to operate its marketplace.

The marketplaces have primarily served low- and moderate-income Americans who don’t get health benefits through an employer or a government program such as Medicare or Medicaid.

They have been buffeted for much of the last year by uncertainty over their future, with insurers in some areas raising rates steeply or exiting markets altogether.

That has been particularly tough for consumers who make too much to qualify for federal insurance subsidies through the healthcare law.

The law offers subsidies to Americans making between 100% and 400% of the federal poverty line, or between $12,060 and $48,240 a year.

Those subsidies likely mean that millions of low- and moderate-income Americans will continue to be able to find relatively low-cost health plans on marketplaces in future years as well.

But continued uncertainty about the markets and the disappearance in 2019 of a penalty for not having coverage could push up rates for consumers who don’t qualify for aid.