President Trump threatened to unleash the Environmental Protection Agency on San Francisco Wednesday after a California visit during which he blamed the homelessness crisis on "liberal" policies.

Mr. Trump accused the city of allowing a tremendous amount of waste, including needles, to go through storm drains into the ocean.

"It's a terrible situation that's in Los Angeles and in San Francisco," Mr. Trump told reporters on Air Force One as he returned to Washington. "And we're going to be giving San Francisco - they're in total violation - we're going to be giving them a notice very soon."

Get Breaking News Delivered to Your Inbox

"They have to clean it up. We can't have our cities going to hell," he said.

CBS San Francisco reports that earlier, while touring a section of the southern border wall in Otay Mesa, California, Mr. Trump criticized San Francisco saying, "It's a total disaster, what's happening. ... We're gonna get involved very soon on a federal basis if they don't clean up their act."

Local officials were quick to fire back.

In a statement, Mayor London Breed called Mr. Trump's remarks "ridiculous" and said storm drain debris is filtered out at city wastewater treatment plants so that none flows "into the bay or ocean."

San Francisco has long struggled with problems of human waste and needles on the streets in the Tenderloin district, where many addicts and homeless people are found. The city set up public toilets and last year announced formation of a special six-person "poop patrol" team to clean up the human waste.

The city also announced funding to hire people to pick up used needles.

Many of those needles came from the city itself. The health department hands out an estimated 400,000 clean syringes a month under programs designed to reduce the risk of HIV and other infections for drug users who might otherwise share contaminated needles.

In her statement, Breed said the city is fighting homelessness by adding 1,000 beds to shelters and wants to pass a $600 million bond to build affordable housing and increase services for people with addiction and mental illness.

California State Senator Scott Wiener also shot back at the president, on Twitter:

More Trump slander against cities, this time San Francisco. Trump is making homelessness & addiction worse by cutting healthcare & affordable housing. I wish Trump would have his EPA enforce against actual environmental problems, but I guess that would be too much to ask. https://t.co/0sruWSVlj1 — Scott Wiener (@Scott_Wiener) September 19, 2019

CBS San Francisco noted that a member of the city's Board of Supervisors, Matt Haney, said Mr. Trump was taking a political shot at the city to whip up his base of supporters.

"Sounds completely ridiculous to me. I don't know why we believe a word that comes out of his mouth at this point," Haney said. "There's no EPA violation. This is someone who doesn't even believe in environmental protections. This just sounds like nonsense. It's unfortunate that the president of the United States is coming to San Francisco choosing to attack our city with lies rather than trying to assist us with more funding for affordable housing."

Mr. Trump, whose two-day fundraising visit to California ended Wednesday, has been bashing California's "liberal establishment" for the surge in homelessness.

On Tuesday, Mr. Trump said his administration "can't let Los Angeles, San Francisco and numerous other cities destroy themselves by allowing what's happening" and vowed to do something about the problem. But at the time, he only mentioned creating a task force.

A day earlier, Gov. Gavin Newsom and mayors of the state's 13 largest cities sent Mr. Trump a letter asking his administration to provide more aid to fight homelessness, including an additional 50,000 housing vouchers for the poor.

But Housing and Urban Development Secretary Ben Carson rejected the housing aid request in a letter Wednesday, saying that California's policies on law enforcement, an overregulated housing market and sanctuary policies regarding people living in the country illegally have driven up housing costs while increasing demand.

"Your letter seeks more federal dollars for California from hardworking American taxpayers but fails to admit that your state and local policies have played a major role in creating the current crisis," Carson wrote.

Carson said nearly 500,000 California households already receive some kind of federal housing assistance and said "federal taxpayers are clearly doing their part to help solve the crisis."

Carson also said ending homelessness has been a "top priority" of the administration.

On Wednesday, Carson toured a Skid Row shelter in Los Angeles and called for cooperation among federal, state and local governments. But he was noncommittal about what he could offer, saying the administration was considering all options, including re-using vacant federal buildings for shelters.

Before more money is spent, Carson said there needs to be more effective use of available housing vouchers. Many of those, including 35% designated for veterans, are not being used, he said.

Carson targeted some of the main hurdles to providing more housing: myriad regulations and opposition from people who don't want poor people living nearby. He said his agency might offer grant preferences to cities that try to remove those barriers to affordable housing.

With close to 60,000 homeless people in Los Angeles County, tents are clustered on sidewalks throughout the city, in vacant lots and under highway bridges. The state's other metropolitan areas have similar situations.

Courts have limited what cities can do to clean up encampments.

On Tuesday, the Los Angeles County Board of Supervisors voted to join an effort to get the U.S. Supreme Court to review a decision that restricts efforts to bar homeless people from sleeping on sidewalks in Western states.

The board voted 3-2 to file a motion supporting Boise, Idaho, in its efforts to overturn a ruling by the 9th U.S. Circuit Court of Appeals that said it was unconstitutional to arrest or otherwise sanction homeless people who sleep on sidewalks when there aren't enough shelter beds.

Supervisor Mark Ridley-Thomas voted in favor, saying he was fed up.

"The status quo is untenable," he said. "We need to call this what it is - a state of emergency," Ridley-Thomas said in a statement.