President Trump (left) listens to EPA Administrator Scott Pruitt in the Rose Garden of the White House after announcing his decision that the United States will withdraw from the Paris Climate Agreement on June 1, 2017. (Kevin Lamarque/Reuters)

Scott Pruitt survived months of misconduct allegations by preserving his relationship with one person at all costs: President Trump.

In the end, according to two administration officials familiar with internal discussions, Trump forced Pruitt out Thursday without speaking to him — instead having his chief of staff call the Environmental Protection Agency around midday to say it was time for Pruitt to go.

That Trump finally parted ways with his EPA administrator was less the result of one particular damaging revelation than the culmination of weeks of negative publicity that was becoming a political burden on the president, according to four White House officials, who, like others interviewed for this story, spoke on the condition of anonymity to discuss the president’s thinking.

“No final straw,” Trump said Thursday, when asked what led to his decision. “Look, Scott is a terrific guy. And he came to me and he said I have such great confidence in the administration. I don’t want to be a distraction. And I think Scott felt that he was a distraction.”

Trump had sought to ignore Pruitt’s problems, officials said, even as he enjoyed spending time with Pruitt, who often struck an adoring tone in his interactions with the president.

After much prodding by numerous advisers, Trump eventually decided Pruitt’s troubles would only grow and that Deputy Administrator Andrew Wheeler  —whom he deemed an “early Trump supporter and a very environmental person” could do just as well, administration officials said.

So he posted the tweet announcing Pruitt’s resignation while aboard Air Force One en route to a rally in Montana and later praised Pruitt as a “terrific guy” — a distinct departure from the terse tweets that ousted former secretary of state Rex Tillerson, former national security adviser H.R. McMaster and former health and human services secretary Tom Price.

“Within the Agency Scott has done an outstanding job, and I will always be thankful to him for this!” Trump wrote.

By the end, Pruitt had few defenders in the West Wing. The White House counsel’s office saw him as a constant source of problems, officials said. Chief of staff John F. Kelly was seemingly obsessed with getting Pruitt ousted, according to EPA and White House officials. Pruitt no longer even returned calls from Cabinet Affairs, the White House department that oversees agencies, White House officials said. His own former aides delivered damaging testimony to Capitol Hill investigators in recent days, confirming media reports, and many in his own agency had turned against him.

Prominent media critics that Trump likes — including Laura Ingraham — said Pruitt was the “swamp” and needed to go.

The White House press office told EPA officials to stop booking Pruitt on TV, according to three current and former aides. Pruitt then began booking his own TV appearances, these people said.

He was also drawing scrutiny from the Office of Management and Budget, which, according to officials, had determined that a $43,000 soundproof phone booth installed for Pruitt at the agency was a violation of federal law. The report has not yet been published, officials said.

Pruitt’s transgressions, in the eyes of many, were overwhelming: His flew first-class and asked aides about securing a military jet, secured a sweetheart apartment rental deal from a lobbyist, and sought government officials to give his wife a job, among other allegations.

The problems will continue for both men: Pruitt still faces a dozen investigations and must file forms disclosing his income —and his wife’s. And Trump must now confirm another EPA head in a razor-thin Senate where Pruitt was popular among some conservatives.

Pruitt’s survival came from being in the line of eyesight — angling to hang around the West Wing while lavishing Trump with praise, telling the president he was “brilliant” and a political revolutionary, according to people who have attended meetings with him.

The two men also commiserated about the “deep state,” along with current and former aides, conspiring against them.

Key presidential allies, like donor Harold Hamm, repeatedly told Trump that Pruitt was actually carrying out his agenda. And Pruitt reinforced some of Trump’s strongest-held beliefs: that climate change was a hoax, that Attorney General Jeff Sessions was not serving him well and that the United States had been ripped off by international trade partners, curent and former officials said.

“My desire in service to you has always been to bless you as you make important decisions for the American people. I believe you are serving as President today because of God’s providence,” Pruitt wrote in his resignation letter.

For some Republican supporters of Trump and Pruitt allies, the ethical mistakes were outweighed by the curbing of the federal government workforce, the eradication of the Paris climate accord, the regulations that were targeted and Pruitt’s willingness to engage with industry executives and lobbyists.

“The president should have protected him better,” said Doug Deason, a Dallas donor and prominent Trump supporter who fund-raises for the pro-Trump America First PAC. “I’m extremely disappointed. He’s the only Cabinet secretary who has done what he was told to do. This is one of the only big blunders of his administration.”

Deason said that Pruitt’s moves at EPA should have outweighed his ethical missteps, which he downplayed.

“I have no idea why the president is doing it,” Deason said. “He is giving in to the loony left and is making a huge mistake.”

Dan Eberhart, another prominent energy industry donor to Trump and the Republican National Committee said that Pruitt made “some questionable personal choices but was the president’s “most effective ally.”

“The president shouldn’t expect the criticism to stop with Pruitt’s resignation,” he said. “Pruitt is just the latest victim.”

Wednesday night, Pruitt was on the White House lawn, watching fireworks explode over the Washington sky.

Pruitt’s chief of staff, Ryan Jackson, was told Thursday morning the resignation letter was needed. It was filled with praise for Trump and signed “your faithful friend.”

EPA aides said Pruitt was nowhere to be seen in the office.