Mr. Kelly, the first former general to occupy the gatekeeper’s post since Alexander Haig played that role for President Richard M. Nixon during Watergate, is charged with quelling the chaos that has defined, distracted and often derailed Mr. Trump’s White House. But the president gave Mr. Priebus many of the same assurances of control, and then proceeded to undercut and ignore him — to the point where Mr. Priebus often positioned himself at the door of the Oval Office to find out whom the president was talking to.
In his brief time at the White House, Mr. Scaramucci seemed to epitomize its chaos. A wealthy New York financier, he burst onto the political scene with a memorable performance in the White House briefing room, where he portrayed himself as a major, new player who had been assured he would report directly to the president, without the interference of intermediaries like Mr. Priebus or Sean Spicer, the president’s first press secretary.
It was soon clear that Mr. Scaramucci would not be a fixture of the administration, but a transitory figure who created an opportunity for Mr. Trump, with his daughter Ivanka and son-in-law Jared Kushner, to undertake the far-reaching shake-up intended to purge the White House staff of leakers and aides viewed as not sufficiently loyal to his cause.
Mr. Spicer quit the day Mr. Scaramucci was hired; Mr. Priebus left shortly after the rant in which Mr. Scaramucci accused him of undermining the president through leaks of information to reporters.
Mr. Kelly, who was Mr. Trump’s first secretary of homeland security, arrives at a critical juncture, when the president is confronted with North Korea’s growing nuclear ambitions, Russia’s aggressive diplomatic moves and continuing fighting in Iraq and Syria. The new chief of staff will also be charged with reviving a stalled legislative agenda. Mr. Trump’s campaign promise to repeal and replace the Affordable Care Act ended in failure last week, and there has been little progress on other major goals like overhauling taxes or rebuilding the nation’s infrastructure.
And despite his desire for discipline, it took only hours on Monday for Mr. Kelly to face his first White House leak, and it was about him. CNN reported that Mr. Kelly had been so upset about the president’s firing of James B. Comey as F.B.I. director in May that he called Mr. Comey to say he was considering resigning, an account that was confirmed by a former law enforcement official who was told of the conversation.
Mr. Kelly resisted the president’s entreaties to take over for Mr. Priebus during the past several weeks. After his appointment was announced on Friday, he met with Mr. Trump and demanded assurances that he would wield the usual sweeping authority over personnel, the flow of information and access to the Oval Office that chiefs of staff have traditionally been given.
In early morning staff meetings at the White House on Monday, Mr. Kelly made it clear that the president had agreed to let him impose more discipline over what had been an unruly and inefficient decision-making and communications process under Mr. Priebus, who had none of Mr. Kelly’s experience in government or the military.
Mr. Kelly also made it clear that everyone in the staff — including Mr. Bannon, Ms. Trump and Mr. Kushner — would clear policy proposals, personnel recommendations and advice from outsiders through him.
“General Kelly has the full authority to operate within the White House, and all staff will report to him,” Ms. Sanders told reporters later. But she added that Mr. Trump would decide how that would work.
Mr. Scaramucci’s fall and Mr. Kelly’s rise highlighted the diminished but still important role in shaping the West Wing played by Ms. Trump and Mr. Kushner, both of whom serve in the White House as senior advisers to the president.
Ms. Trump and Mr. Kushner had hoped to persuade Mr. Trump to appoint Dina Powell, the deputy national security adviser, as chief of staff. Mr. Trump, who likes Ms. Powell, considered doing so, but later — when it became apparent that Mr. Trump had settled on hiring Mr. Kelly — the pair supported the choice of the general, according to people involved in the White House’s internal discussions.
While Mr. Kelly’s concerns were the decisive factor in Mr. Scaramucci’s departure, they said, it was clear that Mr. Trump had quickly soured on the wisecracking, Long Island-bred former hedge fund manager, and so had his family.
Ms. Trump and Mr. Kushner had initially pushed the president to hire Mr. Scaramucci, seeing him as a way to force out Mr. Priebus, the former Republican National Committee chairman, and his allies in the West Wing, like Mr. Spicer.
Mr. Spicer resigned just hours after Mr. Scaramucci’s hiring was made public. And shortly after Mr. Scaramucci called Mr. Priebus a “paranoid schizophrenic, a paranoiac” — adding a more vulgar term to the beginning of the phrase — Mr. Priebus, too, offered his resignation.
Mr. Trump was initially pleased by Mr. Scaramucci’s harsh remarks, directed at Mr. Priebus as well as Mr. Bannon. But that view seemed to change as people around Mr. Trump told him that Mr. Scaramucci’s over-the-top performances were not well received.
In addition, Mr. Scaramucci seemed to be, at least for the moment, overshadowing him — a fact that Breitbart News, which Mr. Bannon used to run, pointed out in a headline describing Mr. Trump as second fiddle to his communications director.
Over the weekend, after speaking with his family and Mr. Kelly — who refused to even consider retaining Mr. Scaramucci — the president began to see the brash actions of his newly high-profile subordinate as a political liability, according to three people familiar with his thinking.
For the time being, the White House may leave the communications director post open, said a person close to the internal discussions about the job, though Mr. Kelly has the latitude from Mr. Trump to fill the post with someone from the Department of Homeland Security.
Two perennial candidates to fill the post are Kellyanne Conway, a White House senior adviser and the president’s former campaign manager, and Jason Miller, who held the communications post during the campaign. Mr. Trump has long wanted to bring Mr. Miller, who serves as an informal adviser, into the administration.
Mr. Kelly’s bond with the president is based on Mr. Trump’s affinity for generals, whom he views as can-do leaders, and a belief that Mr. Kelly is a “star” of the administration, delivering on the promise to secure the border and toughen immigration enforcement.
But the choice was also part of a bet that Mr. Kelly can tame a White House that has at times seemed out of control, even to those inside it. On Monday, after a day that included a cabinet meeting and a ceremony to present the Medal of Honor, Mr. Trump seemed eager for the normalcy that has so far eluded him.
At 6:19 p.m., he said on Twitter: “A great day at the White House!”