WASHINGTON – White House chief of staff John Kelly, who was assigned to bring a level of discipline to President Donald Trump’s often chaotic administration, is leaving the post after internal tensions increasingly spilled into public view.

"John Kelly will be leaving toward the end of the year,” the president told reporters Saturday as he left the White House for the Army-Navy game in Philadelphia.

Trump, who called Kelly “a great guy" despite their clashes, said he will announce a successor – perhaps an interim one – in a few days.

The president was careful not to describe Kelly's exit as a firing, saying that “John Kelly will be leaving – I don’t know if I can say ‘retiring.’" He thanked the former Marine general for his long years of public service.

Kelly himself has not commented publicly since reports emerged Friday that he would be leaving soon.

This is only the latest staff change as Trump shakes up his team in the wake of last month’s congressional elections in which Republicans lost control of the House. Trump has also removed Attorney General Jeff Sessions, and is said to be eyeing other changes.

House Speaker Paul Ryan described Kelly as "a force for order, clarity, and good sense."

More:Nick Ayers passed on chief of staff job. Who else declined White House gigs?

More:White House departures: Who's been fired and who resigned

The Kelly news is not a surprise.

Chris Whipple, author of "The Gatekeepers: How the White House Chiefs of Staff Define Every Presidency," said the Trump-Kelly relationship has been "a lousy marriage" for months.

"No surprise though it was the longest political death watch ever," said Whipple. "Alas, Kelly will be regarded as one of the least effective WH chiefs. Much of that is on Trump, who did not want someone who could tell him hard truths.

Kelly's decision ends a tumultuous 17-month tenure in which he tried, but largely failed, to bring a Marine Corps-style order to a White House that has hewed more closely to the freewheeling management style Trump embraced as a New York businessman.

The retired four-star general had sought to build a tighter organization around Trump, limiting access for staff who grew accustomed to Trump's open-door policy in the Oval Office. But the 68-year-old Kelly increasingly found himself sidelined by a president who chafed at being "managed" by others.

David Cohen, a political scientist at The University of Akron, said the change will probably amount to “little” in the day-to-day operation of the Trump White House.

“Trump has never empowered his chief of staff to actually be a real chief,” Cohen said. “Trump is his own chief in many ways and unwilling to give up any power to his chief subordinate. Until he is willing to make some significant changes to his own management style, nothing will change.”

While officials in July had said Kelly had agreed to stay on through the 2020 election, some of those same officials said more recently that he might move up his timetable. They said Trump has sounded out aides about possible replacements. They include Vice President Pence's chief of staff, Nick Ayers.

In the beginning, Kelly was able to streamline Trump’s schedule and squelch the flow of information that reached his desk – some of which was not vetted before it was repeated on his Twitter feed. On his first day in July 2017, Kelly ousted Trump’s bombastic communications director, Anthony Scaramucci, after he unloaded on colleagues in an interview.

Gradually, however, Trump beat back some Kelly's restrictions, and occasionally complained he was being cut off from friends. Members of Trump's family, including first lady Melania Trump, also complained about Kelly's attempts to limit access.

Months after he followed former Republican National Committee chairman Reince Priebus into the job, reports emerged that Trump had frozen Kelly out, and the president was repeatedly forced to deny murmurs that "the general" was soon to be ousted.

Kelly had to publicly dispute reports he once called Trump "an idiot," that he cast himself as "the lone bulwark against catastrophe" from Trump, and that he got into a shouting match with National Security Adviser John Bolton over Department of Homeland Security Secretary Kirstjen Nielsen's performance on border security.

‘Crazytown’

Journalist Bob Woodward quoted Kelly describing the Trump White House as “Crazytown.”

Trump brought Kelly into a White House riven by internal feuds in July 2017. Weeks after ousting Scaramucci, Kelly orchestrated the departure of senior adviser Steve Bannon, an architect of Trump's campaign who clashed with other members of the staff.

After firing Health and Human Services Secretary Tom Price for spending taxpayer money on high-priced charter flights, he insisted that any future such flights be approved by him personally. And after a scandal over lax security clearances, he rescinded top-level clearances for a number of high-level staffers – including the president's son-in-law, Jared Kushner.

While Trump was careful to praise Kelly in public, the two repeatedly clashed behind the scenes. The chief of staff found himself left out of certain meetings and decisions by or involving the president.

For example, Kelly was not dialed in when Trump phoned Russian President Vladimir Putin in March to congratulate him on winning re-election in Russia. During his first months on the job, Kelly listened in on all foreign leader calls.

Also, the chief of staff was not involved in Trump's decision to hire Bolton as his new national security adviser, an appointment he announced by tweet. Kelly had made it known he was opposed to Bolton in the days before his selection.

At one point, Trump mused about doing away with the chief of staff post altogether, and have various department heads report to him directly. He reportedly told aides he was tired of being told “no” by Kelly.

Still, as Kelly passed the one-year mark in July, administration officials said Trump had asked the chief of staff to stay on through the 2020 election. Kelly told staff members he had accepted the request.

Recent tension

In recent weeks, however, some administration officials expressed concern that Kelly would leave if Trump dismissed Department of Homeland Security Secretary Kirstjen Nielsen, one of Kelly’s proteges.

As Trump announced Kelly's departure on Saturday, Nielsen remained on the job.

Other White House officials praised Kelly for bringing much-needed organization to a notoriously undisciplined president and staff.

His military mind and organizational skills were seen as a good counterpoint to Trump's often impulsive style. Still, Kelly often found himself at the center of stories of White House intrigue.

After Trump told the widow of a soldier killed in Niger that "he knew what he signed up for, Kelly attacked a congresswoman who criticized Trump for being insensitive. He called Rep. Frederica Wilson, D-Fla., an "empty barrel" and "all hat, no cattle." He then falsely claimed that Wilson took credit for an FBI building in her district.

He was slow to take action on Rob Porter, the White House staff secretary, who was able to work for more than a year with an interim security clearance until a British tabloid revealed allegations of domestic violence from his two ex-wives. Even then, he initially put out a statement defending Porter until asking for his resignation a day later.

After many of those episodes, Trump defended his chief of staff on Twitter. He said Kelly was "doing a fantastic job," that he was "one of the finest people I know," and that "I could not be happier or more impressed."

He also seemed to give conflicting signals on the president's support for key administration officials – just before they were fired.

Correction: This story has been updated to remove extraneous word in the first sentence.