He wore a suit and tie for his flight to the hospital. He posed for photos signing blank pieces of paper. He recorded videos declaring himself recovering. He inspired aides to describe him as hard at work. And the infectious patient briefly left the hospital for a drive to wave at supporters.

Throughout his four-day hospitalization with the novel coronavirus, during which time he was administered a cocktail of steroids and therapeutic drugs, President Trump strove to convince the public that he was fully in charge — not only of the country he leads, but also of his own body and care — even if it was not the case.

“Feeling really good!” he wrote Monday on Twitter from his chambers at Walter Reed National Military Medical Center, as he announced his forthcoming discharge. “Don’t be afraid of Covid. Don’t let it dominate your life. We have developed, under the Trump Administration, some really great drugs & knowledge. I feel better than I did 20 years ago!”

The president’s physician, Sean Conley, described Trump as “a phenomenal patient.” And, in a sign that Trump has exerted personal control over deciding his treatments, Conley told reporters on Monday that the president “has been working hand in glove with us.”

It was Trump’s decision to return to the White House, where doctors plan to continue his treatments, and it was supported by Conley and others on the medical team, according to a senior administration official who, like some others interviewed for this story, spoke on the condition of anonymity to candidly discuss the president’s health.

Trump came back to the White House by helicopter late Monday, walking up stairs from Marine One into the residence. He pumped his fist and stopped on the balcony, flanked by flags, and took off his mask for a dramatic photo opportunity. He then walked into the residence, past others, without his mask.

Trump’s quest to come across as commanding even while suffering from a deadly illness that is especially dangerous for men of his age and with his comorbidities is in keeping with one of his great phobias in life: appearing weak.

Trump has sought to mask his physical vulnerabilities with his own machismo and Conley’s rosy assessments of his condition.

“It seems as though Trump is calling all the shots,” said Chris Whipple, author of “The Gatekeepers,” a history of White House chiefs of staff. “He has what he’s always wanted, which is a presidency without any guardrails and without anyone to tell him what he doesn’t want to hear.”

Though Conley told reporters that Trump had not yet recovered from covid-19, the disease caused by the virus, the president was adamant about returning to the White House and encouraged his advisers to tell journalists that he is healthy, according to a Republican official with knowledge of the conversations.

“I have to get out of here,” Trump said in at least one of those calls, pushing back against suggestions that he remain at Walter Reed longer, according to this official.

Some of Trump’s advisers expressed concern about the president’s decision to leave Walter Reed, said someone familiar with the discussions. The worry was twofold, as they both feared for Trump’s health and worried that if the president needs to return to the hospital in coming days, the ensuing news cycle would be a public relations disaster.

Of paramount concern for the president during his hospital stay was his political standing. With the election now just four weeks away, Trump called allies on Monday to discuss the latest polls in various battleground states, what television advertisements his campaign has on the air, and which competitive states he could visit as soon as he can return to the campaign trail and again stage large in-person events.

Trump also has spent time discussing with advisers what kind of dramatic imagery would make him appear presidential and in charge, a White House official said.

White House Chief of Staff Mark Meadows has been at the president’s side consistently in recent days, but other White House aides have grown increasingly frustrated with Meadows for not communicating clearly about the president’s condition or what those working in the West Wing should be doing. This includes members of the White House’s coronavirus task force, according to people familiar with the dynamic.

Trump called advisers such as personal lawyer Rudolph W. Giuliani and campaign advisers Jason Miller and Corey Lewandowski to say that he is strong and ready to return to work and begin campaigning again — messages all three quickly repeated in interviews. Trump was angry that Meadows had indicated he was sick, according to two campaign advisers and a White House official.

Notably quiet during Trump’s hospital stay were Vice President Pence and military officials. They gave no public assurances that the nation was in good hands and that a plan was in place to ensure continuity of government should the president become incapacitated.

That might have been by design, said David Lapan, a former senior official in Trump’s Department of Homeland Security who is now a vice president at the Bipartisan Policy Center.

“You would want to hear the secretary of defense, the chairman of the Joint Chiefs of Staff, the vice president say, ‘Look, we are going through a situation here. We have it well in hand. Make no mistake, our adversaries should not see this as an opportunity. We are fully prepared to execute all of our authorities,’ ” Lapan said.

But, he added, “the president doesn’t want to create an appearance that anybody is in charge except him.”

Indeed, Trump has found a vocal chorus of evangelists to spread his message, publicly taking pains to persuade people that the president is healthy and full of vigor.

“President Trump won’t have to recover from COVID. COVID will have to recover from President Trump.#MAGA,” Rep. Matt Gaetz (R-Fla.) tweeted Monday morning.

Sen. Kelly Loeffler (R-Ga.) also tried to flatter Trump. In a tweet Monday, Loeffler posted a video of a long-ago publicity event in which Trump tackled WWE chairman Vince McMahon to the ground outside a wrestling ring — only this time, the video was doctored so that McMahon’s head was instead a 3-D rendering of the virus.

“COVID stood NO chance against @realDonaldTrump!” Loeffler wrote.

Inside Trump’s orbit, there was considerable consternation about his Sunday evening appearance outside Walter Reed, where he waved at supporters from inside an armored vehicle.

Though the president wore a mask, the event risked infecting two Secret Service agents who were in the vehicle, as well as other personnel the president may have encountered coming and going from his hospital quarters. The move drew widespread criticism from health officials, including a Walter Reed attending physician who was not directly involved in the president’s care.

One senior administration official defended the outing, claiming that Centers for Disease Control and Prevention protocols were followed, Trump’s medical team approved it, Secret Service agents used personal protective equipment, and the two who drove with him volunteered to do so.

Assessing how it would play politically, Miller said: “Anyone who hated that [outing] hates the president anyway.”

But a second senior administration official expressed far more discomfort — especially over the president endangering the lives of Secret Service officers sworn to protect him.

“First they have to take a bullet for the guy,” this official said. “Now they have to get the ‘rona.’ ”

Other officials were aghast at the photo op, which was reminiscent of others pushed personally by the image-obsessed Trump and executed on the fly.

After the 2016 release of the “Access Hollywood” video in which he bragged about sexual assault, then-candidate Trump stepped out of Trump Tower in New York to mingle with supporters who had gathered to cheer him.

And on June 1, amid nationwide protests of racial injustice, Trump opted to leave the White House, walk across Lafayette Square flanked by an entourage and pose for photos while holding a Bible in front of St. John’s Church. Federal officers used rubber bullets and chemical irritants to clear peaceful protesters from the area for the president’s photo op.

It is unclear, however, whether anyone working for Trump could have stopped him from executing his plan for, as he put it Sunday in a video, “a little surprise.” That is the kind of role that ordinarily would fall to the White House chief of staff.

“You have to wonder if anyone is performing that job, because no competent White House chief of staff would ever have permitted a president with a lethal disease to go take a joyride, thereby threatening the health of the Secret Service,” Whipple said. “It’s just absolute chief of staff malpractice.”

Meadows has long had a reputation of being a Trump sycophant, dating to his time in Congress earlier in the administration. He has drawn criticism inside the White House for sugarcoating things for the president — and, in the view of his critics, for being at times two-faced and duplicitous.

Thomas F. “Mack” McLarty III, a former chief of staff in the Clinton White House, was loath to directly criticize Meadows or his operation. But McLarty explained that a chief of staff’s duty during a medical crisis involving the president is to immediately address the situation with the Cabinet, White House staff and Congress with clear guidance and regular updates.

“This is a pretty unprecedented situation,” McLarty said. “It was unexpected and you’re dealing with it as best you can. You obviously have emotions about the president and the first lady, particularly when you see that helicopter lifting off to Walter Reed.”

But, he added, “It behooves any White House to find their footing quickly and to get their coordination and communication efforts in really tight sync.”

For now, at least, the person in charge of doing so is the patient.

“It’s been a very interesting journey,” Trump said in a video message released Sunday night. “I learned a lot about covid. I learned it by really going to school. This is the real school. This isn’t the ‘let’s read the book’ school, and I get it, and I understand it. And it’s a very interesting thing, and I’m going to be letting you know about it.”