“We must earn and keep the public trust and continue to hold ourselves to the very highest standards,” Mr. Rosenberg wrote in the internal email. “Ours is an honorable profession and, so, we will always act honorably.”

Mr. Trump has injected the White House into law enforcement matters in ways that have made many career officials uncomfortable. The president spoke disparagingly about ongoing criminal investigations into his own associates, encouraged the Justice Department to investigate political rivals including Hillary Clinton and said he would never have nominated Jeff Sessions to be attorney general if he had known Mr. Sessions would recuse himself from an investigation into his associates.

Mr. Rosenberg, who was appointed by President Barack Obama in 2015, is a career prosecutor. Under President George W. Bush, he served as the United States attorney in both southern Texas and eastern Virginia.

In late July, Mr. Rosenberg, told the deputy attorney general, Rod J. Rosenstein, that he did not want to be considered as the permanent administrator of the D.E.A. Mr. Rosenstein, who wrote a memo that Mr. Trump briefly cited as his rationale for dismissing Mr. Comey, then asked whether Mr. Rosenberg wanted to remain at the Justice Department, and Mr. Rosenberg said he did not.

In a message to D.E.A. employees on Tuesday, Mr. Rosenberg said, “The neighborhoods in which we live are better for your commitment to the rule of law, dedication to the cause of justice and perseverance in the face of adversity.”