The White House promptly accepted Mr. Shaub’s resignation and Lindsay E. Walters, a White House spokeswoman, said in a statement that it “appreciates his service.” Mr. Trump, she said, would nominate a successor “in short order.”
In departing ahead of schedule, Mr. Shaub has handed Mr. Trump an opportunity to begin putting his mark on the agency overseeing the federal government’s vast ethics program, including that of the White House. The office’s director traditionally has had wide latitude to set its priorities, its tone in working with the White House and other federal agencies and, perhaps most important, how to interpret the country’s ethics laws.
The impending vacancy is all but certain to raise fears among Democrats and those in the small world of government ethics who see the office under Mr. Shaub as an important political bulwark against conflicts of interest in the upper echelons of the government. To Mr. Trump’s defenders, who have seen Mr. Shaub, an Obama appointee, as politically motivated, it is more welcome news.
The intensity of feeling over what is usually an obscure job speaks to the central role ethics have come to play in Mr. Trump’s Washington, where the vast holdings of the president and his cabinet, as well as an influx of advisers from businesses and lobbying firms, have raised a rash of accusations of conflicts of interest.
It is the job of the ethics office, a creation of a post-Watergate Congress, to work with a web of ethics officials at each agency to help those entering the government sidestep potential conflicts. The office guides each administration’s political appointees though financial disclosure requirements and creates agreements to restrict participation in deliberations over topics they handled for paying clients.
Mr. Shaub, 46, has faced an uncertain future at the agency since Mr. Trump took office in January. In the weeks between the president’s unexpected election victory and his inauguration, Mr. Shaub had taken an extraordinary gamble: He advocated very publicly on Twitter, and in a rare public speech, that Mr. Trump liquidate his vast business and personal holdings. The arrangement, Mr. Shaub argued, was the only truly ethical option.
Mr. Trump did not heed his advice, and by the middle of January, Mr. Shaub thought he might be fired. To minimize his attachment to the position, he packed up the personal possessions that filled his office.
But he was not fired, even as he continued to spar with Mr. Trump’s aides over a range of ethical concerns, including the ethics office’s authority to exercise oversight of the White House.
In February, he recommended that the White House discipline Kellyanne Conway, a top adviser to the president, after she made an on-air endorsement of the clothing line of Ivanka Trump, the president’s daughter. The White House Counsel’s Office disagreed and took no disciplinary action.
More recently, Mr. Shaub and the administration fought over a routine request by the ethics office for copies of waivers issued to White House appointees to work in the Trump administration. The Office of Management and Budget initially balked at the request, challenging Mr. Shaub’s legal authority even to ask for the information and asking him to withdraw it. After Mr. Shaub fired back with a stern 10-page letter shooting down the argument, the White House backed down.
The White House eventually released the waivers, showing it had granted at least a dozen exemptions for aides to work on policy matters they had handled as lobbyists or to engage with former colleagues in private-sector jobs. Mr. Shaub objected to the fact that many of the waivers were undated and unsigned, and that some gave approvals for acts retroactively.
Mr. Shaub, who served for about a decade as a career civil servant at the agency before being appointed director, said his role had always been politically neutral. Rather than fighting Mr. Trump, as some critics have suggested, Mr. Shaub has said his decisions to speak out have been motivated by a desire to defend an ethics program that traditionally has counted on support from Democrats and Republicans alike. He said he spoke publicly only after other more traditional channels were exhausted.
Mr. Shaub will leave the agency this month to take up his new position as a senior director for ethics at the Campaign Legal Center in Washington, a nonpartisan group that advocates campaign finance reform and litigates voting rights cases. There, Mr. Shaub will have more freedom to comment on the government’s ethics program and propose a set of changes he said are needed badly.
News of Mr. Shaub’s impending departure was greeted on Thursday with more acquiescence than surprise. Those who have worked in the ethics office or in the White House said it raised pressing questions over whether Mr. Trump’s choice of Mr. Shaub’s successor would quiet the agency’s criticism.
“I don’t think anyone who comes after Walter is going to challenge the White House publicly the way that I think he did,” said Richard W. Painter, who served as ethics counsel for the George W. Bush White House. “It is a great loss.”
Mr. Painter said the administration would do itself a favor by naming a successor with experience in ethics law and a reputation for independence.
A permanent replacement for Mr. Shaub would require confirmation in the Senate, where Democrats would probably use confirmation hearings to raise grievances about what they see as Mr. Trump’s own potential conflicts of interest and Republicans are unlikely to act as a rubber stamp.
The White House could also elect to simply leave the position to an acting director indefinitely. Shelley K. Finlayson, the office’s chief of staff, is first in line for the acting director position, but the law governing such vacancies also allows the White House to choose from among the office’s upper ranks.
That arrangement, the experts said, could help preserve the office and allow it to go about much of its work. Or, it could simply be a quieter way to effectively neutralize it, said Marilyn L. Glynn, who served as the agency’s acting director during the George W. Bush administration.
“Based on my experience as acting director, you clearly don’t have the visibility and power that a full director would have,” Ms. Glynn said. “That is one way of keeping the office fully below the radar.”