When White House Chief of Staff John F. Kelly stopped by the Oval Office to see President Trump late Wednesday, Kelly said he couldn't stay long because reporters were in his office waiting for a briefing on immigration policy.

Deciding not to leave the session to his top aide, Trump walked down the hall minutes later and made a surprise appearance in Kelly's office. The president proceeded to field a rush of questions on the Russia investigation with answers that rattled his lawyers and senior aides and left Kelly dealing with the fallout.

The episode illustrates the unusual and sometimes strained relationship between the garrulous president and his second chief of staff, who has imposed sharp restrictions on many of Trump's friends — and even his children — as Kelly seeks to direct the flow of information and influence in the Oval Office.

Trump has at times bristled at the restrictions and, in recent weeks, has openly chafed at the idea that Kelly, not he, is effectively running the business of the White House, associates say. Kelly stayed behind in Washington this week while Trump traveled to the Davos global summit in Switzerland — a change of plans that prompted notice among those close to Trump.

Yet the two also remain close in many ways, making the up-and-down dynamics a guessing game for those who work with them. While the two men fight and swear at each other at times, Kelly sees Trump more than anyone else, and confidants say the volatility in their relationship is natural. Trump has often interrupted meetings to ask Kelly's opinion and has told others he respects the former Marine general's time in the military and his stature, according to White House officials and people who know them.

"Is that right?" Trump asked Kelly a number of times during a recent meeting, seeking his perspective as they met with Reps. Mark Meadows (R-N.C.) and Raúl R. Labrador (R-Idaho), according to people with knowledge of the meeting. 

Trump critics have questioned whether Kelly's style of managing the president is always best. While he has sometimes kept bad information from getting to the president, he has also intervened to block bipartisan deals that Trump wanted to strike on immigration and reinforced some of the president's most contentious positions. Several of Trump's most controversial and racially incendiary moments — such as his remarks last summer after riots in Charlottesville and his recent disparaging comments about African nations — also came as Kelly looked on.

Scenes from Trump’s second year in office

Jan. 8, 2019 | President Trump speaks on television from the Oval Office during a national address on border security on the 18th day of the partial government shutdown. (Jabin Botsford/The Washington Post)

Trump has lashed out when he feels Kelly is getting too much credit or taking too much of the spotlight, friends and associates said. The president was furious last week when Kelly said Trump was "uninformed" in his call for a border wall during the 2016 presidential campaign, according to two people familiar with those discussions, who requested anonymity to describe Trump's reaction.

"A lot of people know the border wall is the dumbest idea," said Chris Whipple, author of a book on presidential chiefs of staff. "Kelly made the mistake of saying it aloud on Fox." 

Trump has joked to associates that Kelly has cut his phone line, outside advisers said. He has told friends that he can come by "only if the general approves." And the president has complained that he never sees staff members anymore and occasionally sits in the office alone, aides said. 

"As long as you're being useful to the president, then he's more likely to keep you around," said Ed Brookover, a longtime campaign adviser. "But you can't ever forget that we have initials, too: JFS. We're 'just freaking staff.' "

One reason Trump stays in the personal residence section of the White House so late every morning — sometimes until after 10 a.m. — is because he has access to his phone and has fewer restrictions, associates say. Kelly has told others he is fine with such "executive time," as it is referred to on his schedule. 

"General Kelly is not here to manage the president," said presidential counselor Kellyanne Conway. "He's here to manage the paper and people flow to the president to ensure that the president has ample time to listen, to think, to deliberate before he makes a decision that impacts people's lives and livelihood."

Kelly has slashed security clearances into the West Wing and reduced the number of people on the access list that once allowed relative free roaming within the White House, officials said. People such as former campaign manager Corey Lewandowski have seen their access reduced, with Kelly requesting that they work through him on all visits.

After Lewandowski had a lengthy meeting at the White House with Kelly this month, he went to say hello to a friend from the campaign, White House counsel Donald McGahn, according to people familiar with the incident. When Jim Carroll, a White House lawyer, saw Lewandowski sitting in the waiting area without an appointment with McGahn, he told the operative that he had to leave and offered to escort him out, the people said, requesting anonymity to describe sensitive exchanges. They added that escorts for all guests are now part of White House culture.

Kelly has told others there was too much wandering around without escorts, and now everyone has to sign in and say where they are going. He remains amazed that Michael Wolff, author of a controversial tell-all book released this month, was able to sit around in the West Wing for countless hours last year, aides say.

The chief of staff has told people that Trump's schedule shouldn't be as packed as it was, and has encouraged the president to show him tweets, though he has told others he can't do much about them, according to White House officials. Kelly has routinely listened as Trump rages about the Russia investigation, a senior administration official says, and acts as a "sounding board." 

Kelly brings fewer issues to the president than Reince Priebus, his first chief of staff, did, and often will advise Trump of issues after they have been handled.

He has curbed the role of the president's daughter, Ivanka Trump, and her husband, Jared Kushner, in the White House, aides say, and has at times questioned Ivanka Trump's work on Capitol Hill. A senior White House official said Kelly was supportive of her approach. 

Kelly's views on personnel and policy are shared only with a group of people he trusts, including Homeland Security Secretary Kirstjen Nielsen; Marine Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff; and Defense Secretary Jim Mattis, also a former general. At the White House, he confides in White House aide Johnny DeStefano, deputy Joe Hagin and Rob Porter, the president's staff secretary. Kelly calls Nielsen "Secretary Kirstjen" occasionally, reflecting the closeness of their relationship.

Kelly's relationship with the Cabinet in which he once served is mostly businesslike. He has reached out to and met personally with several members in recent months, including Housing and Urban Development Secretary Ben Carson, in an effort to bolster those relationships, according to a person who has helped to arrange dinners. Kelly frowns upon Cabinet members making overtures to Trump without communicating with him first.

A cross-section of aides in the West Wing say they think Kelly has made things better. 

"In terms of helping the president, he brings order to a pretty chaotic situation," said Sen. Lindsey O. Graham (R-S.C.). "There is not enough adjectives to describe him because General Kelly has done a really good job putting in a process for the president to make better decisions."

Trump, however, prefers a free-flowing style and is mercurial, changing his position intermittently. Time and again, he will see an issue on TV and want something done, leaving Kelly in a tough spot. 

"Trump of all people needs more managing than any of his predecessors," Whipple said. "But he gets tired of people quickly. Six months with Donald Trump is an eternity. Just ask Reince Priebus." 

David Nakamura and Ashley Parker contributed to this report.