Homelessness in the United States rose for a third straight year, the federal government reports, propelled by a sharp increase in California, a state that is struggling with stratospheric housing prices and being challenged by the Trump administration to take further action.

A decline in homelessness in 29 states, as well as the District of Columbia, was offset by a spike in California of 21,000 people, or 16.4 percent, the Department of Housing and Urban Development announced Friday — evidence that homelessness in the nation’s most populous state is “at a crisis level and needs to be addressed by local and state leaders with crisis-like urgency,” HUD Secretary Ben Carson said in a statement.

California leaders and advocacy groups share federal officials’ alarm over the state’s outsize role in that trend. But there’s significant disagreement over how to tackle the issue as the president singles out cities like San Francisco and Los Angeles as problems, clashing with a liberal state that often fights his policies.

The figures are from single-night surveys done in January. Nearly 568,000 people were counted as homeless across the country this year, according to HUD, representing a 2.7 percent increase over last year and a continuation of the reversal of steady declines in homelessness from 2010 to 2016. Still, homelessness nationwide is nearly 11 percent lower than it was in 2010 — though the homeless count in California is 22.5 percent higher today than it was nine years ago.

The latest numbers could fuel the Trump administration’s recent interest in combating homelessness in California, as the president decries damage to the “prestige” of the country’s cities and laments people living on its “best highways, our best streets, our best entrances to buildings.” Federal officials are considering creating new temporary facilities and refurbishing existing ones, along with the controversial measure of razing encampments, The Washington Post reported this fall.

Divides over the best approach were on display Friday as Carson discussed the new homelessness numbers on “Fox & Friends,” criticizing local policies that let people sleep in public places as fueled by a “misguided concept of what compassion really is.”

“Compassion is getting that person into a situation where they can become self-sufficient,” Carson said, arguing that people allowed to sleep in the open have less incentive to seek out resources.

Homeless advocates argue that shelters and other aid can’t meet the growing unsheltered population’s needs, even as some alarmed cities commit big new chunks of funding. Many champion a “housing first” approach — the idea that people need a place to live before they can stabilize their lives — as Trump appoints a new top homelessness official who has advocated “housing fourth,” wary of policies he says are “enabling” the people who are struggling.

“Simply cracking down on homelessness without providing the housing people need is not a real solution,” San Francisco Mayor London Breed told CityLab earlier this year, speaking to a city where local media outlets have reported that the waiting list for shelters often tops 1,000 people.

State and local leaders in California say they’re working hard to combat homelessness, allocating $1 billion this year for anti-homelessness programs in what Gov. Gavin Newsom (D) touted this month as the state’s biggest investment ever.

They’ve also questioned the Trump administration’s commitment to helping.

“California is doing more than ever before to tackle the homelessness crisis, but every level of government, including the federal government, must step up and put real skin in the game,” Newsom said earlier this month.

In another seeming jab at the administration, the governor announced that California would be advised by Matthew Doherty — the Obama appointee ousted last month as head of the U.S. Interagency Council on Homelessness.

Neither HUD nor Newsom’s offices immediately responded to requests for comment Saturday.

Homelessness is hard to quantify. Counts come from volunteers who spend one night in January surveying as many people as they can find, and the numbers they arrive at are likely incomplete: Research suggests that New York City’s count may catch just half of people living without shelter.

Experts say California’s standout statistics stem from high housing costs as well as mental health and substance abuse problems and legal hurdles to getting people off the streets — all issues that could complicate federal officials’ ideas to stage an intervention, as The Post’s Scott Wilson reported earlier this year.

Carson, too, highlighted issues of affordability in his statement Friday, describing a rise in “street homelessness along our West Coast where the cost of housing is extremely high.”

While HUD said California accounts for “more than the entire national increase” in homelessness this year, another Western state had a bigger jump from 2018 to 2019: New Mexico’s homeless population rose by 27 percent, according to federal data.

Idaho, West Virginia, Kentucky and Minnesota also saw increases above 10 percent, HUD said.

Amid the discouraging trends, officials spotlighted some areas of improvement. The number of homeless veterans counted around the United States decreased by about 2 percent from last year — and has been cut in half since 2010, HUD said. The count for families with children experiencing homelessness also dropped about 5 percent from 2018.

Read more: