We are shocked The president was visiting the Walter Reed military hospital outside Washington, where he met wounded soldiers and health care workers.
"I've never been against masks but I do believe they have a time and a place," he said as he left the White House.
He has previously said that he would not wear a mask and mocked Democratic rival Joe Biden for doing so.
But on Saturday he said: "I think when you're in a hospital, especially in that particular setting, where you're talking to a lot of soldiers and people that, in some cases, just got off the operating tables, I think it's a great thing to wear a mask."
The change of tone came as the US recorded 66,528 coronavirus cases on Saturday, a new daily.
What has Trump said about face masks?
Speaking to Fox Business Network last week, Mr Trump said: "I'm all for masks."
He added that he "sort of liked" how he looked with one on, likening himself to the Lone Ranger, a fictional masked hero who with his Native American friend, Tonto, fought outlaws in the America.
But when the US Centers for Disease Control (CDC) in April began recommending people wear masks or cloth coverings in public to help stop the spread of the virus, Mr Trump told reporters he would not follow the practice.
"I don't think I'm going to be doing it," he said back then. "Wearing a face mask as I greet presidents, prime ministers, dictators, kings, queens - I just don't see it."
Some media reports have suggested aides have repeatedly asked the president to wear one in public.
In an interview with the Wall Street Journal last month, Mr Trump suggested some people might wear masks.
He also said he took issue with people touching their faces after taking their mask off.
"They put their finger on the mask, and they take them off, and then they start touching their eyes and touching their nose and their mouth. And then they don't know how they caught it?" he said.