President Donald Trump on Saturday wore a mask in public for the first time since the coronavirus pandemic began, after repeated urging from aides that it was a necessary message to send to Americans resistant to covering their faces.

Trump wore a dark mask affixed with the presidential seal during a visit to the Walter Reed National Military Medical Center, where he planned to visit wounded troops. He was surrounded by Secret Service agents and others also wearing masks.

Anticipation over whether he would wear a mask had been building, after the president had repeatedly dismissed suggestions that he wear a mask, frequently appearing in public spaces without one, mocking those who did and ignoring public health rules in several states.

Trump had recently told reporters he planned to wear a mask. Before going to the hospital, he stopped to speak with reporters at the White House.

“I’ll probably have a mask, if you must know,” Trump 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. I’ve never been against masks, but I do believe they have a time and a place.”

Weeks ago, the president took a mask off before seeing reporters during a tour of a Ford plant in Michigan, in violation of factory policy, which he said he did to avoid being photographed with it on.

In contrast to Trump’s reluctance, a growing number of governors, both Republican and Democratic, have taken up the cause in recent weeks. Gov. Doug Ducey of Arizona, and Gov. Brian Kemp of Georgia are among the chorus of Republican officials who have encouraged their constituents to actively cover their faces in public.

Sens. Lisa Murkowski of Alaska, Lamar Alexander of Tennessee and Mitt Romney of Utah have also called on the president to wear face coverings, at least as a symbolic gesture. Gov. Andrew Cuomo of New York has also implored the president to wear one.

Trump had signaled more recently that he was more open to masks, as the pandemic has spread to states with large numbers of Republican voters. In an interview this month, he said he “would wear one if I were in a group of people and I was close,” adding that he “sort of liked” the way he looked.

“It was a dark black mask,” he said at the time, “and I thought it looked OK. I looked like the Lone Ranger.”

This article was written by Maggie Haberman, a reporter for The New York Times.