Trump flew by helicopter to Walter Reed National Military Medical Center to meet wounded service members and health care providers caring for COVID-19 patients.
Health officials recommended the facial covering for Trump as a precaution against spreading or becoming infected by the novel coronavirus.
As he left the White House, he told reporters: “When you’re in a hospital, especially ... I think it’s a great thing to wear a mask.”
Read Also: Face coverings recommended, but Trump says he won't wear one
Trump was wearing a mask in Walter Reed’s hallway as he began his visit. He was not wearing one when he stepped off the helicopter at the facility.
However, the president was a latecomer to wearing a mask during the pandemic, which has raged across the US since March and infected more than 3.2 million and killed at least 134,000.
Most prominent Republicans, including Vice President Mike Pence, endorsed wearing masks as the coronavirus gained ground this summer.
Republican governors have been moving toward requiring or encouraging the use of masks as the pandemic has grown more serious in some states in the South and West.
Trump, however, has declined to wear a mask at news conferences, coronavirus task force updates, rallies and other public events.
According to the people close to him, the president feared a mask would make him look weak and was concerned that it shifted focus to the public health crisis rather than the economic recovery. They spoke on condition of anonymity to describe private matters.
While not wearing one himself, Trump sent mixed signals about masks, acknowledging that they would be appropriate if worn in an indoor setting where people were close together.
He accused reporters of wearing them to be politically correct and retweeted messages making fun of Democratic rival Joe Biden for wearing a mask and implying that Biden looks weak.