WASHINGTON — President Trump said late Wednesday that his administration would issue a notice of environmental violation against the city of San Francisco because of what he described as its homelessness problem.

Traveling aboard Air Force One as he returned to Washington from a three-day trip to California and New Mexico, Mr. Trump told reporters that San Francisco was in “total violation” of environmental rules because of used needles that were ending up in the ocean.

“They’re in total violation — we’re going to be giving them a notice very soon,” the president said, indicating that the city could be put on notice by the Environmental Protection Agency within a week that its homelessness problem was causing environmental damage.

He said tremendous pollution was flowing into the ocean because of waste in storm sewers, and he specifically cited used needles.