WASHINGTON — Faced with a torrent of criticism from cities and states that have been pleading for help to deal with the most critically ill coronavirus victims, President Trump announced on Friday that the federal government would buy thousands of ventilators from a variety of makers, though it appeared doubtful they could be produced in time to help hospitals that are now overwhelmed.

His announcement came shortly after authorizing the government to “use any and all authority available under the Defense Production Act,” a Korean War-era authority allowing the federal government to commandeer General Motors’ factories and supply chains, to produce ventilators.

It was the latest example of Mr. Trump’s mixed messages about how to ramp up production to meet a national crisis. Just 24 hours before, he had dismissed the complaints of mayors and governors who said that they were getting little of the equipment they needed for an expected onslaught of serious cases. And this week he praised companies that — General Motors included — were rallying to help provide necessary equipment.

But he turned on G.M. on Friday, accusing it of “wasting time” and seeking to “rip off” the government. “Our fight against the virus is too urgent to allow the give-and-take of the contracting process to continue to run its normal course,” the president said.