He attended a closed-door fund-raiser at a private home of a wealthy supporter in Minneapolis, and he appeared before thousands of people at a rally in Duluth, Minn., where most of the crowd did not wear masks. He also shared a stage with Mr. Biden.
It is not yet clear when and how Mr. Trump contracted the virus. The president and the first lady said they had both tested positive hours after one of his closest aides, Hope Hicks, also tested positive. Ms. Hicks received the diagnosis after she began experiencing symptoms on Wednesday while attending the president’s rally in Minnesota. Mr. Trump kept his appearance there to about 45 minutes, roughly half the length of one of his typical rally speeches.
Early Friday morning, it was still unclear how many other aides who had come into close contact with Mr. Trump had tested positive, but the White House said its medical unit was conducting contact tracing. Top advisers to the president described themselves as in a state of shock and said they expected a number of additional cases among people in Mr. Trump’s orbit. White House officials had hoped to keep the news about Ms. Hicks from becoming public, to no avail.
Mr. Trump, for his part, has been fatalistic when talking with associates about whether he or others would get sick, describing the possibility as a roll of the dice. His week included a series of events in which he played down the virus in front of crowds large and small, all without wearing a mask.
On Monday in the Rose Garden, Mr. Trump boasted about the progress he said that his administration had made toward increasing testing capacity.
“I say, and I’ll say it all the time: We’re rounding the corner,” Mr. Trump said. He was joined by Vice President Mike Pence; Alex M. Azar II, the health secretary; Betsy DeVos, the education secretary; and the chief executive of Abbott Laboratories, Robert Ford.
On Tuesday Mr. Trump was accompanied by all of his adult children and senior members of his White House and campaign staff on Air Force One en route to Cleveland for the first presidential debate. None of them wore masks as they were seen boarding and deplaning. Bill Stepien, the president’s campaign manager, was seen on board without a mask and then was spotted getting into a staff van with Ms. Hicks.
Onstage in Cleveland, Mr. Trump mocked Mr. Biden, the Democratic presidential nominee, for his habit of wearing a mask in public.
“I think masks are OK,” Mr. Trump said, adding: “I put a mask on when I think I need it. Tonight, as an example, everybody’s had a test and you’ve had social distancing and all of the things that you have to, but I wear masks when needed.”
The president then addressed Mr. Biden, saying: “I don’t wear a mask like him. Every time you see him, he’s got a mask. He could be speaking 200 feet away from them and he shows up with the biggest mask I’ve ever seen.”
Few in the president’s circle appeared to be taking any precautions on the Cleveland trip. Those on Air Force One Tuesday evening included Jason Miller, the campaign strategist; Stephen Miller, the White House policy adviser; Mark Meadows, the White House chief of staff; Robert C. O’Brien, the national security adviser who tested positive for the virus in July; and Representative Jim Jordan, Republican of Ohio. All were seen on the plane without masks.
On the flight home from the debate, Jared Kushner, the president’s senior adviser and son-in-law, could be seen in a staff cabin, speaking animatedly to his colleagues with no mask covering his face. Upon landing at Joint Base Andrews in the middle of a heavy rainstorm, Lara Trump, the president’s daughter-in-law, and Kimberly Guilfoyle, a senior campaign official and the girlfriend of Donald Trump Jr., the president’s eldest son, huddled to share an umbrella as they crossed the tarmac, talking and laughing. Ms. Guilfoyle tested positive for the virus over the summer.
In contrast, the East Wing has taken a different approach to safety. The first lady, Melania Trump, who posted a photograph of herself wearing a mask on Twitter before her husband reluctantly and halfheartedly endorsed the practice, has made the majority of her staff members work from home, with aides entering the building on a rotating basis. When she has traveled with the president, she has done so without members of her own advance staff, to avoid more exposure to the virus.
After the debate, the president’s eldest daughter, Ivanka Trump, posted a rare photograph of herself with her mother-in-law, along with Tiffany Trump and Lara Trump, huddled together backstage, wearing masks. But the family members removed their masks in the debate hall shortly before the event began.
On Wednesday evening, a small coterie of advisers spoke with one another about Ms. Hicks’s symptoms as they flew home aboard Air Force One. Ms. Hicks was isolated in a separate cabin. She exited from the back of the plane, as opposed to the front.
By Thursday, it was clear that something unusual was happening at the White House, aides said. Several staff members who have avoided masks were suddenly wearing them.
On Thursday evening, before his own diagnosis was made public, Mr. Trump sounded raspy on a call with Iowa voters and in an interview later with Sean Hannity on Fox News. Some aides chalked it up to a busy week of campaigning.
Annie Karni reported from Washington, and Maggie Haberman from New York.