Just when America had all but given up hope, Scott Pruitt’s appalling reign as Environmental Protection Agency administrator is finally over. Thursday afternoon, Mr. Pruitt delivered President Trump his resignation letter, replete with references to “God’s providence” and how “blessed” he was to have had the opportunity to serve not the nation, but this president. He sadly noted that “the unrelenting attacks on me personally, my family, are unprecedented and have taken a sizable toll on all of us.” And so Mr. Pruitt heads for the door, leaving behind a dark, oily stain on the office that he has spent the past year and a half vigorously defiling.

Mr. Pruitt’s departure did not come as a total shock. Word around Washington in recent weeks was that the stench of corruption wafting from E.P.A. headquarters was getting to be too much even for Mr. Trump. Someone in the White House no doubt noticed that, with the midterms approaching, Mr. Pruitt was not playing well with any voter who retains some common sense. In an administration characterized by extreme swampiness and ethical flexibility, the E.P.A. chief had nonetheless distinguished himself with pathological grifting to the point that even some Republican lawmakers and reliably conservative commentators had begun publicly slapping him.

Still, for months, Mr. Pruitt held on to his job as the embarrassing revelations piled up like so many used mattresses: his profligate spending on posh travel, over-the-top security, and ridiculous, self-aggrandizing office supplies; his directing agency staffers to run his personal errands, including finding him a place to live in Washington and combing hotels for his favorite skin cream; his attempts to score his wife a high-paying job, possibly involving chicken nuggets and waffle fries. Every week seemed to bring fresh examples of Mr. Pruitt’s shameless and yet surprisingly petty misuse of his office.

Mr. Trump’s willingness to tolerate Mr. Pruitt’s chicanery was not surprising. The two men share an environmental philosophy that may be roughly summarized as “industry over science,” and, for all his flaws, Mr. Pruitt was tireless in the crusade to dismantle environmental protections. His greatest hits include playing a key role in getting Mr. Trump to withdraw the United States from the Paris climate agreement; pushing the repeal of numerous Obama-era regulations, including those to cut greenhouse gas emissions from power plants and automobiles; and instituting a policy that barred scientists who receive federal grants from serving on the E.P.A.’s advisory committees, while simultaneously welcoming corporate representatives onto these panels. Just last month, The Times reported that the E.P.A. had decided for the most part not to consider exposure to chemicals through the air, water or ground when it is evaluating whether they should be regulated or banned under a bipartisan law passed in 2016.