WASHINGTON — 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 Donald Trump’s persistent attacks on the health law.

The new enrollment numbers — which include totals from 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 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.”

Florida, which uses HealthCare.gov, and California, which operates its own marketplace, 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 health care 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 from 2017 to 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 percent 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 percent increase, and Rhode Island, which led all states with a 12.1 percent 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 percent, 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.

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.

In neighboring Arizona, which also has experienced significant turmoil in its insurance market, enrollment fell 15.6 percent in 2018, one of the largest drop-offs in the country.

Arizona relied on the federal government to operate its marketplace.

noam.levey@latimes.com