President Trump is trying to take command of his floundering administration by enlisting a retired four-star Marine general as his White House chief of staff, empowering a no-nonsense disciplinarian to transform a dysfunctional West Wing into the “fine-tuned machine” the president has bragged of running but which has not yet materialized.

John F. Kelly will be sworn in Monday at the nadir of Trump’s presidency, with historically low approval ratings, a stalled legislative agenda and an escalating Russia investigation that casts a dark cloud.

Trump envisions Kelly executing his orders with military precision and steely gravitas, and without tending to outside political motivations or fretting about palace intrigue, according to Trump confidants. The president replaced Reince Priebus with Kelly, who had what Trump considers a star run as homeland security secretary, in the hope of projecting overall toughness and of inspiring the respect — and even fear — that has eluded him on Capitol Hill, where fellow Republicans last week defied the White House on health care and Russian sanctions.

But no matter how decisive his leadership, Kelly alone cannot turn Trump’s vision into reality. Warring internal factions that have stirred chaos, stoked suspicions and freelanced policies for six straight months may not easily submit to Kelly’s rule. And the president — whose rash impulses routinely have sabotaged the best efforts of his senior aides — has shown no willingness to be tamed.

“Kelly is an incredibly disciplined person who could bring order to the process if the animals in the zoo behave,” said John E. McLaughlin, a former acting director of the CIA who served in seven administrations. “The danger he has is that Trump will be Trump.”

Kelly got a quick introduction to his new life on Saturday: an angry tweet storm from Trump in which he told Senate Republicans to “Get smart!” and change chamber rules to make it easier to pass his priorities, saying that the senators “look like fools.”

If Kelly has been recruited to bring order to a turbulent White House, the first decision he must make is where to concentrate his energies.

There is not a single model for White House chiefs of staff, as all are derivative of the president’s style and preferences. But broadly, chiefs of staff can be viewed as either managing the president or managing the government, managing up or managing down and out.

In Trump’s White House, given the personality of the president and the clashing world views among the senior staff, Kelly might be forced to do both.

“It will be a challenge for someone who has demonstrated great discipline, General Kelly, to be able to introduce President Trump to some of the discipline he should have in the Oval Office,” said Andrew H. Card, who was President George W. Bush’s first White House chief of staff. “Great generals do not allow impulse to dictate how they are going to inspire other people to do their jobs. Generals appreciate the consequence of decisions.”

No one disputes that Trump’s White House lacks discipline. This dynamic was not an accident. It was designed that way by the president-elect during the transition. Experts on government management knew from the minute Trump named Priebus as his first chief of staff and anointed Stephen K. Bannon as chief strategist with virtual coequal standing that this was going to be a White House with competing power centers.

These days, there are three camps in the Trump White House, factions that sometimes meld: family, represented by daughter Ivanka Trump and son-in-law Jared Kushner; Trump campaign loyalists, including Bannon and counselor Kellyanne Conway; and GOP establishment figures, such as Vice President Pence and other senior aides.

Kelly, who comes from none of those camps, is being grafted onto the existing body. He is well liked by all three factions and has forged a particularly close bond with two members of the Cabinet: Secretary of State Rex Tillerson and Defense Secretary Jim Mattis. The three men have formed a rapport as older, calmer presences in Trump’s orbit navigating tricky policy directives that frequently overlap.

In the White House, Kelly could form a natural alliance with national security adviser H.R. McMaster, a three-star Army general who has struggled to take full control over the national security process.

As some administration officials texted and called each other Saturday to discuss Kelly, there was widespread angst, since few of them were familiar with his leadership style.

To get a grasp of his personality, people familiar with Kelly urged White House aides and agency leaders to read books by conservative writer Bing West, a retired Marine, who has extensively chronicled Kelly’s military tenure in titles such as “The Strongest Tribe” and “The March Up.”

One particular scene in “The March Up” was passed around by several Trump associates as a sign of how Kelly operates: tersely and with little tolerance for complaints.

After Kelly saw the bodies of Iraqi civilians alongside a road, West writes, he warned his commanders that so many civilian casualties was not acceptable — a point that prompted a defensive response from the commanders about how they were just trying to protect their troops.

“‘Don’t go there with me,’ [Kelly] shot back, cutting off debate,” West writes. “He had been in the infantry thirty years and knew the range of every weapon.”

Trump advisers also checked in with friends at the Department of Homeland Security, asking what they had gleaned from Kelly’s time there. They shared two immediate takeaways: first, that Kelly had not been directed with a heavy hand from the White House on whom to hire as his deputies, and second, that he is driven by duty and a passion for enforcing the law rather than by ideology.

Throughout his life, Trump has venerated military valor, and he recruited several generals into his administration, including Kelly. He admired Kelly’s decisive moves to crack down on illegal immigration and border crime and first sought him out for the chief of staff role in mid-May. Trump was rebuffed multiple times until Kelly agreed this past week to take the job.

Even as confidants suggested other options for chief of staff, Trump kept coming back to Kelly. The collapse this week of the Republican health-care bill sped up the president’s timetable to replace Priebus, according to people familiar with the move.

Kelly comes into the post as more of an equal to the president than Priebus, both generationally — Kelly is 67 and Trump is 71, whereas Priebus is 45 — and in stature.

“The kinds of people that Trump particularly likes are people with bucks — money — and braids — the military,” said Martha Kumar, director of the White House Transition Project.

Although Kelly does not bring legislative experience, Trump sees him as part of the solution to his administration’s legislative woes, according to people familiar with the decision to bring Kelly to the White House. Instead of hiring an insider who would ingratiate himself or herself on Capitol Hill, Trump wanted someone who adds stature and commands respect from congressional leaders, the people said.

Over recent months, Trump concluded that Priebus’s close relationship with House Speaker Paul D. Ryan (R-Wis.) became a hindrance, giving Ryan leverage and insight into the workings of the White House. He resented the suggestion that Priebus was a “Trump whisperer” who had to explain Trump to Ryan and other GOP leaders, these people said.

So far, most of the administration’s accomplishments have been overturning or reversing Obama-era policies. But Kumar said Kelly could help reorient the White House around a “positive policy agenda.”

When Kelly made the rounds on Capitol Hill before his nomination hearings in January, he did not know Trump very well and asked people there to share stories about the president-elect. He wanted to know how Trump made decisions. Told that Trump relished competing power centers around him, Kelly grimaced and said nothing.

Those who knew Trump before he became president knew that his management approach, short attention span and general lack of discipline were a recipe for trouble. Trump’s early transition planners envisioned a White House table of organization that started with a strong chief of staff and that included clear lines of authority and limited direct access to the president.

But Trump got what he wanted: a White House in which the power and influence of individuals ebbed and flowed, with status affected by Trump’s aims of the moment, his limited loyalty toward any of those in his employ and the backstabbing that has been a constant feature almost from Day 1.

Trump’s transition documents included a lengthy memo about White House structure, based on past administrations. “They didn’t follow the product at all,” said a person with direct knowledge of what transpired as Trump was setting up his administration. “They did it instinctively … The president-elect didn’t want to say no to anybody.”

The result was the White House that now exists, populated by advisers with competing ideologies that reflect an administration that is an amalgam of populist nationalists, hard-line conservatives and establishment Republicans — and a few Democrats. Trump saw this grouping as his winning coalition in the presidential campaign and as encompassing his disparate views on the issues, but it has added greatly to the lack of coherence once he took office.

“The only way a chief of staff can be successful is if he is empowered by the president, and I never had any feeling that Reince Priebus was fully empowered by the president,” said Rep. Charlie Dent (R-Pa.). “The success of Kelly will be significantly dependent upon how much authority President Trump grants him.”

The environment is poised to change in the Kelly era. The new chief of staff is expected to have full control over the Oval Office and schedule, officials said. Trusted aides such as Hope Hicks, Dan Scavino and Keith Schiller — as well as senior advisers such as Kushner, Bannon and Conway — will continue to have casual access to the president.

But Kelly is expected to have a far tighter grip than Priebus was able to exercise on who participates in meetings and the process by which policy decisions are made.

“The vast majority of people who work in the White House are quite competent and quite self-confident,” Card said. As chief of staff, he added, “You want to make sure that they recognize that their competence is needed, but their self-confidence should be managed.”

One possibility mentioned by Kelly associates as a deputy chief of staff is Christian Marrone, a Republican who served in President Barack Obama’s administration as chief of staff to Homeland Security Secretary Jeh Johnson. Marrone declined to comment.

Many of Trump’s top aides chafed at taking instructions from Priebus. When Anthony Scaramucci was hired as communications director this month, he received an assurance from Trump that he would report to the president, not to the chief of staff.

Chris Whipple, author of “The Gatekeepers,” a history of White House chiefs of staff, said Kelly’s task will be “mission impossible” if his control is not absolute.

“If Scaramucci reports directly to President Trump, therein lies disaster,” Whipple said. “You can’t have a loose cannon rolling on the deck. Kelly has to make sure he’s in charge of the White House staff, in charge of the information flow to the president, and in charge of executing policy. And fundamentally, he’s got to be able to go in, close the door, and tell Trump what he does not want to hear.”