The director of the independent Office of Government Ethics, who has been the federal government’s most persistent critic of the Trump administration’s approach to ethics, announced Thursday that he is resigning nearly six months before his term is scheduled to end.

Walter M. Shaub Jr. repeatedly challenged the Trump administration, publicly urging President Trump to fully divest from his business empire and chastising a senior Trump adviser for violating ethics rules. His outspokenness drew the ire of administration officials and earned him near-cult status among Trump’s opponents. Fans started a Facebook page in his honor, and his name has occasionally appeared on posters at anti-Trump protests.

Shaub made no reference to those clashes in a resignation letter he posted Thursday indicating he will step down July 19. Instead, he praised the work of federal ethics officials, pointedly noting their commitment to “protecting the principle that public service is a public trust, requiring employees to place loyalty to the Constitution, the laws, and ethical principles above private gain.”

In an interview, Shaub said he was not leaving under pressure, adding that no one in the White House or the administration pushed him to leave. But the ethics chief said he felt that he had reached the limit of what he could achieve in this administration, within the current ethics framework.

“It’s clear that there isn’t more I could accomplish,” he said.

Walter Shaub, Director of the United States Office of Government Ethics, said he felt that he had reached the limit of what he could achieve in this administration, within the current ethics framework. (Linda Davidson/The Washington Post)

[How the U.S. ethics chief took on Trump and became a reluctant Washington hero]

Shaub is set to take a new job as senior director of ethics at the Campaign Legal Center, a nonprofit legal advocacy group founded by Trevor Potter, who served as a Republican appointee to the Federal Election Commission. Shaub said he hopes to find bipartisan solutions to strengthening government ethics programs at the federal and state levels.

“In working with the current administration, it has become clear that we need to strengthen the ethics program,” he said.

Reacting to Shaub’s resignation, White House spokeswoman Lindsay Walters said, “The White House accepts Mr. Shaub’s resignation and appreciates his service.” She said the president would nominate a successor “in short order.”

Created in 1978, the ethics office is designed to promote and protect laws intended to prevent conflicts of interest by government officials. The office offers ethics guidance and training for government officials and oversees employees’ annual disclosure of personal finances, but it has limited enforcement authority.

Directors are appointed by the president and confirmed by the Senate to five-year terms — a length of time intended to give the office independence by ensuring directors’ terms overlap presidential administrations.

Shaub’s departure is likely to spur anxiety among ethics officials and critics of the president who viewed him as one of the few federal officials who had been willing to speak out when he viewed the administration departing from past ethics norms. Trump allies cast him as a grandstander and noted he had been appointed by President Barack Obama.

Upon Shaub’s departure, the ethics office’s chief of staff, Shelley K. Finlayson, is expected to assume the role of acting director, although Trump could appoint another senior OGE official to serve temporarily until he chooses a permanent replacement. In 2014, Shaub described Finlayson as “a tireless advocate for OGE’s mission” and praised “her reliably cool judgment.”

Shaub, who before his appointment had served in other roles at OGE and as a lawyer at other federal agencies dating to 1997, was named OGE’s director in 2013 and had been scheduled to serve until January.

In a statement, Senate Minority Leader Charles E. Schumer (D-N.Y.) promised that Democrats would closely scrutinize Trump’s selection to replace Shaub, insisting the nominee “must demonstrate that they are committed to actually draining the swamp and ensuring administration officials are not using their positions for personal gain.”

Norman Eisen, who served as Obama’s chief White House ethics lawyer, called Shaub “one of the great public servants of the executive branch.”

“In his own understated and nonpartisan way, this is a protest resignation,” Eisen said.

Shaub’s willingness to challenge the Trump administration was apparent even before Inauguration Day. On the morning of Nov. 30, the official OGE Twitter account erupted in a storm of nine tweets sent over three minutes that appeared to mimic Trump’s bombastic tweeting style, urging the president-elect to separate himself from his business.

“.@realDonaldTrump OGE is delighted that you’ve decided to divest your businesses. Right decision!” read one tweet.

“.@realDonaldTrump OGE applauds the ‘total’ divestiture decision. Bravo!” read another.

Trump had in fact made no such decision. The tweets appeared designed to use Trump’s own tactics of praise and flattery to urge him do so. Internal OGE emails later released through public information requests showed that Shaub himself had drafted the notes and directed that they be sent.

When Trump announced on Jan. 11 that he would retain ownership of his business, merely transferring management to his adult sons Eric Trump and Donald Trump Jr., Shaub aired his concerns in an unusually public address at the Brookings Institution. He denounced the plan as “wholly inadequate” and insisted Trump should place his assets in a fully blind trust over which his family would have no control.

“The ethics program starts at the top,” he said. “We can’t risk creating the perception that government officials will use their positions for personal profit.”

[Federal ethics chief blasts Trump’s plan to break from businesses]

In March, Shaub chided the White House over its failure to discipline senior aide Kellyanne Conway after she urged viewers on Fox News to “go buy Ivanka’s stuff,” a reference to the apparel line owned by the president’s daughter. Federal law prohibits government employees from endorsing brands or products.

The White House said Conway had been speaking in a “light, off-hand manner” and was unlikely to violate the rule again. In a letter, Shaub responded that failing to take action against a senior official risked “undermining the ethics program.”

More recently, Shaub has clashed with the White House over his efforts to gather data about former lobbyists and other federal appointees who had been granted waivers to ethics rules allowing them to interact with their former employers while serving in the White House or at federal agencies.