WASHINGTON — Environmental Protection Agency Administrator Scott Pruitt resigned Thursday, ending a tenure marked by allegations of misconduct that led to repeated calls for his ouster and embarrassed President Donald Trump.

Pruitt, a former Oklahoma state attorney general, was accused of spending extravagantly on travel and security, asking aides to run personal errands and accepting favorable terms for the rental of a condo owned by the wife of an energy lobbyist.

A government watchdog agency concluded earlier this year that the installation of a $43,000 soundproof telephone booth for Pruitt violated congressional appropriations law.

But Pruitt worked aggressively to roll back environmental regulations that Trump and his allies viewed as burdensome to businesses. That won him praise from the president, who stood by his embattled EPA chief for months.

"Within the Agency Scott has done an outstanding job, and I will always be thankful to him for this," Trump wrote on Twitter as he announced Pruitt's resignation.

Trump said Pruitt's deputy, Andrew Wheeler, would replace him.

In his resignation letter, Pruitt effusively praised Trump, saying he considered it "a blessing to be serving you in any capacity." But Pruitt said the "unrelenting attacks" had taken a toll on him and his family.

Democrats hailed Pruitt's departure, but still expressed concern about environmental stewardship under a Trump administration.

"Took you long enough," tweeted Sen. Charles Schumer, D-N.Y., at Trump. "Still a very long way to go to fully #DrainTheSwamp."

Rep. Frank Pallone, D-N.J., the ranking member on the House Energy Commerce Committee, said Pruitt’s resignation was “long overdue.”

“He repeatedly violated the law, abused his position to enrich himself, and wasted taxpayer money,” Pallone said. “Pruitt created a culture of corruption at EPA that has never been seen before in a federal agency, and for months President Trump idly stood by and allowed him to do further harm.”

Pruitt and his allies including Sen. Ted Cruz, R-Texas, claimed he was the target of a leftwing conspiracy to get rid of him because of his aggressive efforts to undo Obama-era rules. By shedding Pruitt, the president has lost his most ardent and effective deregulator.

In a follow-up tweet after Pruitt resigned, Trump said his new environmental administrator Wheeler "will continue on with our great and lasting EPA agenda."

Later, speaking to reporters while traveling to Montana, Trump said there was “no final straw” for Pruitt and the resignation was “very much up to him.”

“I think Scott felt that he was a distraction,” Trump said.

Trump and his aides had expressed concern about Pruitt's behavior -- "bothersome," one spokesman said this week -- but had not publicly moved to dismiss him until Thursday, a day after Pruitt and other Cabinet members attended a July Fourth picnic at the White House.

Earlier in the year, Trump praised Pruitt in public and said he was being targeted by political enemies; but he has been much more reticent in recent weeks.

But the president's endorsement didn't stop some Republicans in Congress from joining the Pruitt-must-go chorus. About 170 Democrats on Capitol Hill had called for his ouster and several prominent Republicans said it might be time for a change. He's currently facing more than a dozen federal investigations examining his conduct and ethics.

Pruitt's departure sets up a potentially bruising confirmation battle in the Senate with whomever Trump nominates as the next EPA administrator.

Long list of ethical concerns
Sen. Joni Ernst, R-Iowa, who is unhappy with Pruitt's moves to reduce ethanol consumption that is economically important to Midwestern states, recently called the EPA administrator "as swampy as you can get."

Among the recent ethical challenges and criticisms:

Aides running errands

A top assistant to EPA Administrator Scott Pruitt conducted personal errands for her boss last year, including booking personal flights, hunting for homes and inquiring about the availability of a used mattress from Trump International Hotel.

The errands performed by aide Millan Hupp were revealed as part of testimony she provided in May to the House Oversight and Government Reform Committee.

Huge raises for aides

As scrutiny mounted over his first-class flights, top aides received huge pay raises after the White House rejected them.

Pruitt paid $50 a night to rent a room on Capitol Hill in an apartment owned by health care lobbyist Vicki Hart, who is married to energy lobbyist J. Steven Hart. He used it beginning in February 2017 when he became EPA administrator and paid only on the nights he stayed until he moved out in July of that year.

EPA's senior ethics official, Kevin Minoli, recently reviewed the lease — months after he had vacated the apartment — and deemed that the arrangement did not violate agency rules. That was not enough for the White House which launched its own investigation.

"We take this seriously and we're looking into it," White House Press Secretary Sarah Sanders said Wednesday.

Pruitt went on Fox News that day to defend his conduct, unapologetically calling his arrangement similar to an"Airbnb situation" where lodgers only pay for the nights they stay, and countering the criticism that renting from a energy lobbyist is a potential conflict. He blamed the "toxicity" of Washington for contributing to the firestorm and said the criticism is "about the mission we're engaged in here."

But even the interview was apparently mishandled because Pruitt went on the air despite a report from the Washington Post that the White House asked him not do so, displaying no contrition for his actions.

Asking Trump to fire Sessions

CNN reported that Pruitt had asked that the president fire Attorney General Jeff Sessions and instead appoint him to run the Justice Department, according to a report by CNN.

He made the request during an Oval Office meeting with Trump in spring, CNN reported, citing three anonymous sources. Advisers shot down the idea but Trump has floated the option as recently as April.

Their meeting and the request came amid multiple federal reviews of Pruitt and continued criticism of his ethics and policy.

Secret calendar

A former staffer opened up about Pruitt's office and its method of scrubbing unflattering meetings from his official calendar.

Kevin Chmielewski, Pruitt's former deputy chief of staff for operations, told CNN that Pruitt kept secret calendars and schedules that included meetings with executives and one in 2017 with Cardinal George Pell, who later was charged with sexual assault.

"We would have meetings what we were going to take off on the official schedule. We had at one point three different schedules. One of them was one that no one else saw except three or four of us," Chmielewski told CNN.

The manner of deleting records and hiding official documents could be a violation of federal laws.

Pruitt had faced increasing public criticism and ethics reviews in recent months as expenses over security measures, first-class flights and a sound-proof communications system came to light.

The Atlantic reported the EPA chief bypassed the White House to give large raises to favored aides who had come with him from Oklahoma, where he was attorney general.

Despite the drumbeat of unfavorable publicity concerning Pruitt's personal conduct, Trump admired the job EPA was doing taking apart environmental regulations. During a March 29 speech in Ohio to tout his infrastructure initiative, the president praised the agency for moving to speed up environmental reviews of large projects.

"We've really streamlined the system; where we have really made it possible for people to get things done," Trump told the crowd of union laborers in Richfield, Ohio. " So many projects are under construction right now that would never, ever in a million years have gotten built."

Picked to reshape EPA
It was clear when Trump picked Pruitt that he wanted someone who would not only dismantle Obama-era environmental initiatives but reshape the culture of an agency hard-line Republicans have long slammed as a political instrument to carry out a leftist agenda that impedes economic growth.

As Oklahoma's attorney general, Pruitt had sued the agency 14 times on behalf of the state challenging a variety of regulations and billing himself as “a leading activist against EPA’s activist agenda.”

A month after he took the helm in February, 2017, the budget released by President Trump, an ardent EPA critic himself, proposed gutting the $8.2 billion agency by nearly a third. Congress ended up restoring most of the cuts.

Pruitt was opposed loudly by hundreds of former EPA employees, and more quietly by some current ones. They feared he would assist the petrochemical industry he grew close to in Oklahoma while ignoring the carefully constructed science that served as the foundation of many public health protections.

Subsequent cuts in pollution enforcement and the departure of hundreds of veteran EPA staffers through a buyout program have given environmental groups more reason to worry.

During Pruitt's 14 months at the helm, he began rolling back the Clean Power Plan targeting carbon emissions from energy plants and delayed implementation of the Waters of the U.S. rule aimed at improving water quality.

He announced the agency would undo the Obama administration's proposed reduction in auto emissions for cars and light trucks first set in motion in 2012 as part of its campaign to reduce greenhouse levels that contribute to climate change. Industry voices and other critics contend the changes, spurred by tough limits imposed by California, would drive up costs for consumers.

But there were subtler changes as well that struck at the core of the EPA's mission as defined by previous administrations.

The agency did away with the “sue-and-settle” approach that Pruitt said improperly allowed the Obama administration to circumvent laws by rewriting regulations behind closed doors with friendly environmental groups who filed lawsuits.

The agency also rewrote membership rules for the agency’s advisory boards, so that both industry advocates and academics from Midwestern and Mountain states — which Pruitt said were under-represented — have greater influence when counseling agency leaders on new rules.