John Kelly, who has been President Donald Trump’s chief of staff since last July, will be leaving the White House by the end of the year, the president said Saturday.“John Kelly will be leaving toward the end of the year,” Trump told reporters on Saturday, describing him as "a great guy."Trump said he would be announcing Kelly's replacement in the next few days.The sudden announcement came a day after widespread reports that Kelly was on his way out amid a frosty relationship with the president.There have been semi-regular panics about Kelly’s coming divorce with Trump basically since the moment he took the job. At the end of July, Kelly told White House staff that the he planned to stay in his role until the end of the 2020 presidential election, and that Trump wanted him to stay on even longer. But that agreement was never taken seriously inside and outside the White House and became even more precarious after the midterm elections.Kelly came to Trump with a reputation as a clear-headed manager and a determination to impose order on an unruly White House. But a series of missteps and a fraying relationship with the president dwindled his authority and credibility inside the White House. In the months leading up to Kelly’s departure, the president, who doesn’t like to fire staff, took little input from his top aide on major decisions, according to sources, and often asked outside advisers for names of possible replacements.Sources close to the administration also told BuzzFeed News they were surprised by how long Kelly had lasted, despite Trump making the job harder and making his intention to nudge the chief of staff out clear. Kelly's relationships have been worsening this fall throughout the White House — NBC News reported in November that Kelly has frustrated First Lady Melania Trump over travel and staffing issues, and he has had heated fights with National Security Adviser John Bolton and his team.The departure comes as many other top Trump officials exit the administration after the midterm elections, including Jeff Sessions.The outgoing chief of staff had been finding himself at the center of a number of unflattering stories. He reportedly denigrated the president to staff. Kelly has referred to Trump as an “idiot” on several occasions, NBC reported in late April, frustrated over the president’s understanding of policy. Kelly, the report said, has also suggested to staffers that women are more emotional than men. Kelly called the story “total BS.”Kelly’s reputation as a clear-headed manager was undermined in early February, when Kelly ally Rob Porter resigned as White House staff secretary amid allegations of physical and emotional abuse by his two ex-wives. In his role as staff secretary, Porter vetted all information that hit Trump’s desk, wielding great influence in the White House, as a result, partially by Kelly’s design.Kelly reportedly knew of the allegations against Porter last fall, and the White House has offered conflicting accounts of who in the administration knew about Porter and when.In the Daily Mail’s initial story reporting the allegations made by Porter’s ex-wives, Kelly told the tabloid, “I can’t say enough good things about” Porter, and that he was “proud to serve alongside him.” Kelly also reportedly urged Porter to stay on at the White House even after the Daily Mail report was published.But within days, Kelly revised his own timeline of the week, reportedly instructing staff to say he had kicked Porter out of the White House within 40 minutes of learning of the allegations — a version of events that White House staff believed untrue, the Washington Post reported, and was contradicted by public statements released by the White House.That story about Kelly — who prided himself in slowing leaks during his tenure as chief of staff — spoke volumes about how his stature in the White House had shifted. On Feb. 13, FBI Director Christopher Wray again contradicted the White House account, saying the agency had passed along information about Porter in March 2017 when he was undergoing a background check in a bid to get a security clearance. By early March, in an impromptu briefing with reporters, Kelly attempted to clarify what had happened. He again offered a confusing timeline of events, but he admitted that the Porter scandal could have been handled better. “We didn’t cover ourselves in glory in terms of how we handled that on Wednesday morning; it was confusing,” he said.The episode, and its fallout, has also frustrated the Trump family.Kelly implemented a new security protocol in late February, blocking top clearance for White House officials who have had long-running background checks. That new process resulted in Jared Kushner, Trump’s son-in-law and top adviser, losing his top-level security clearance. Trump’s family is said to blame Kelly for Kushner’s situation, which was only resolved in late May.Kelly, who replaced Reince Priebus in the top White House job, had previously been credited with imposing some semblance of internal staff order on an often-messy White House. One of his first and most significant actions was overhauling the information flow to the president, limiting both personal access to Trump and the type of news he sees.Trump has reportedly balked at Kelly’s tight control over information. Still, Kelly was limited in his ability to completely control what news the president consumes, especially during the “executive time” hours in the morning and night when Trump is stationed in his residence watching Fox News or liberally calling friends to vent. Trump has also spent more time in the last month outside the confines of the White House, whether that be frequent campaign rallies or just walking outside to visit with “Fox And Friends.”Kelly also appeared to cross a red line with the president in January, when he told members of Congress that some of Trump’s positions during his campaign were “uninformed” and that he “had a lot to do with” the president’s changed position on border security. Trump has frequently fumed about aides who appear to take credit for his stances or success, something that helped lead to the downfall of one-time top aide Steve Bannon.Despite his initial depiction as a calming influence at odds with Trump’s bombast, Kelly shares many of cultural and political views. As commander of the U.S. Southern Command, for instance, he railed against news reporters in 2015, saying “self-appointed and self-anointed critics” of policy at Guantanamo Bay “don’t even understand” the “core values” of military personnel: “loyalty, duty, respect, selfless service, honor, integrity, personal courage.”As chief of staff, Kelly also took up some of Trump’s most pugnacious fights. Kelly personally condemned a Democratic congresswoman who criticized Trump, referring to her as an “empty barrel” and falsely telling reporters that she had bragged about landing funding for an FBI building in Florida.During a Fox News interview around the same time, Kelly also furthered Trump’s arguments against removed statues of Confederate soldiers, suggesting that the Civil War was spurred by "the lack of an ability to compromise" and calling Robert E. Lee "an honorable man" who was loyal to his state. "It made me cringe,” a source who has advised the Trump administration told BuzzFeed News of the interview at the time.Kelly has lately found himself seemingly out-of-the-loop. He’s spent some of his workday in recent months at the gym in the Eisenhower Executive Office, two sources confirmed to BuzzFeed News. Kelly, Bloomberg reported in late March, has not been included on calls to foreign leaders, or in the room for major personnel decisions, including the decision to replace national security adviser H.R. McMaster with Bolton. In October, Bolton and Kelly reportedly got in a shouting match just outside the Oval Office over immigration, which ended with Kelly leaving the White House for the day.Trump appeared to find a way around Kelly’s attempts at control: just working around him entirely.