Mr. Trump did not immediately trust her when she was hired at the White House. She had no prior relationship with him, and according to “American Carnage,” a recent book by Tim Alberta, the chief political correspondent for Politico Magazine, she wept on election night at the fact that he won — an account confirmed by White House officials.

But she was immediately installed outside the Oval Office. Mr. Trump, who was whipsawed and overwhelmed by his own surprise victory, has historically cared a great deal about who guards access to him; at Trump Tower, it was a role of considerable influence. With so much to learn and so many jobs to fill, he had little choice but to go along with the staff that was provided to him, according to current and former officials. Mr. Trump was told by Mr. Priebus that she could be trusted.

Mr. Priebus eventually left the White House, but Ms. Westerhout developed her own relationship with her perennially suspicious boss. The president appeared happy to see her when she would pop her head into his office to try to interrupt a meeting that had dragged on too long, even if he shooed her away, according to White House aides.

The president had grown to trust her and had grown fond of her. According to Mr. Alberta’s book, Mr. Trump would refer to Ms. Westerhout as “my beautiful beauty.” She was often at his side on trips to Mar-a-Lago, his Palm Beach, Fla., resort, where she would accept gifts on behalf of Mr. Trump and trade business cards with his supporters. Some of them knew that if they wanted to reach the president by phone, they could bypass his other gatekeepers and go directly to her.

But she also had a fairly large coterie of enemies, including some in the East Wing — the purview of the first lady, Melania Trump — which viewed her with suspicion. Some of the president’s friends counseled him over the past two years that she was, in the words of one, “immature,” and was blocking access to him from some people he had known for years.

She had also raised suspicion with her indiscreet comments about the president, including openly complaining to aides that Mr. Trump had disrupted his own schedule because he had been late leaving the White House residence after his daily executive time sessions, according to one former official.

Inside the faction-split White House, Trump loyalists cheered Ms. Westerhout’s departure as a move that was long overdue, and said they hoped it served as something of a wake-up call for Mr. Trump to bring in more loyalists into the West Wing. But current and former officials also expressed alarm about what information Ms. Westerhout could share down the road, not just about the president, but about her colleagues.