The White House eventually released the waivers, which showed that 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 approved actions 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. He says he has not been fighting Mr. Trump, as some critics have suggested, but that, rather, his decisions to speak out have been motivated by a desire to defend an ethics program that has traditionally counted on support from Democrats and Republicans alike. He said he spoke publicly only after more traditional channels were exhausted.

Mr. Shaub has continued to make a case for his line of reasoning. In an interview on Thursday with CBS News, he said Mr. Trump’s decision not to liquidate his assets meant there was now “an appearance” that his businesses were profiting from the presidency.

“You can’t be sure,” Mr. Shaub said. “America should have the right to know what the motivations of its leaders are, and they need to know that financial interests — personal financial interests — aren’t among them.”

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, he will have more freedom to comment on the government’s ethics program and to propose a set of changes he said were needed badly.

News of Mr. Shaub’s 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.