Walter Shaub, who as head of the federal government’s top ethics watchdog has clashed repeatedly with the Trump administration, will step down later this month, exiting office nearly six months before his term was to finish.

Shaub, the head of the Office of Government Ethics, will leave office on July 19, he announced in a letter posted to Twitter. He confirmed his departure to The Washington Post, and will start a new job as senior director of ethics at the Campaign Legal Center, a nonprofit watchdog. Shaub took what could be interpreted as a parting shot at President Trump in his note.

“The great privilege and honor of my career has been to lead OGE’s staff and the community of ethics officials in the executive branch,” he wrote. “They are committed to protecting the principle that public service is a public trust, requiring employees to place loyalty to the Constitution, laws, and ethical principles above personal gain” (emphasis in original).

Shaub, a career government lawyer appointed to his current post by Barack Obama, was expected to leave the job at the end of his term. He has repeatedly clashed with the president and his aides, who have presented OGE with perhaps the most ethically fraught administration in modern history, riven with conflicts of interest and possible violations of the law even as it entered the White House.

That strange situation made Shaub, a stocky, nondescript, bureaucrat, into an unlikely heartthrob and hero for some of the president’s critics. His face appeared on t-shirts and a Facebook fan group, surely a strange reversal for an office accustomed to toiling in dusty obscurity—and for Shaub, a man so self-effacing and austere that he stripped his office of all decorations.

“I wanted to not be so attached to this office that I’d be afraid to lose it,” he told The New York Times.

The president has refused to make the customary disclosure of his tax returns, and while most commanders in chief have placed their assets in a blind trust, Trump established a structure that hands control of his company over to his sons, and which was universally dismissed by ethics experts as inadequate. He controls a hotel in Washington, in what some lawyers contend is a violation of both government rules and the Constitution’s Emoluments Clause. In area after area, the president has appeared to be using his office as a method of enriching himself, most recently with a Republican National Committee fundraiser hosted at the the hotel.

Shaub’s relationship with the new president began on a contentious note. In November 2016, after President-elect Trump said he was developing plans to remove himself from running his businesses, the OGE Twitter account delivered a string of missives, apparently written in mock-Trumpian tone, saying that the office recommended total divestiture and noting that OGE had delivered that advice to the president’s aides privately as well. The tweets were a break in protocol for an agency that typically does its business behind closed doors. They were briefly removed, then added again, and public records later revealed that Shaub himself had composed the tweets.

After Trump released his separation plan in January, Shaub branded it “wholly inadequate” and said, “This is not a blind trust. It’s not even close.”

That earned Shaub a rebuke from then-Representative Jason Chaffetz, the Republican chair of the House Oversight Committee, who said OGE should not engage in public relations. White House Chief of Staff Reince Priebus seemed to threaten Shaub, saying he must “be careful” about criticizing Trump.

Shaub also sparred with the White House over waivers granted to former lobbyists to serve in the administration. Like previous presidents, Trump issued a series of rules intended to show he would keep tainted lobbyists out of the government, and like previous presidents, he granted waivers to some people to get around the rules. Unlike previous presidents, however, Trump attempted to keep the waivers secret. In April, Shaub requested information on them. The following month, Mick Mulvaney, director of the Office of Management and Budget, suggested OGE had no authority to seek the waivers and asked that Shaub suspend his inquiry. Shaub refused.

“The unusual nature of your letter highlights OGE’s responsibility to lead the executive branch ethics program with independence, free from political pressure,” he wrote. “Accordingly, OGE declines your request to suspend its ethics inquiry.”

The White House eventually gave in, releasing the waivers, which covered several top officials.

In February, after Nordstrom announced it would stop selling a line of clothing under Ivanka Trump’s name, Trump adviser and spokeswoman Kellyanne Conway recommended that people go out and buy Ivanka Trump goods. The incident was a signature example of crossover between Trump’s political aides and his family’s private fortune. The OGE found that Conway’s statement violated rules against federal employees using their office to encourage use of private products, and Shaub recommended that she be disciplined.

But that case also showed the limitations of Shaub’s power. Though OGE can recommend punishment, it has no enforcement mechanism, and only an employee’s boss can dole out sanctions. In the case of Conway, that was Trump, and the president clearly had no interest in scolding his daughter’s defender.

Shaub told the Post that he decided he had reached the limit of his ability to effect change in the job. “It’s clear that there isn’t more I could accomplish,” he said. His departure means Trump will be able to choose his own ethics chief, which is all but assured to produce a friendlier presence at OGE. Even without an internal persecutor, however, Trump’s violations of ethical norms will remain a problem. The battle is just likely to shift away from the executive branch and toward Congress, the courts, and the public.