William Bradford, a Trump appointee who sent racist and anti-Semitic tweets before being chosen to lead the Energy Department’s Office of Indian Energy, resigned from his position on Thursday.

“Bradford tendered his resignation this afternoon and is no longer with the Department of Energy, ” Shaylyn Hynes, an Energy Department spokeswoman, said by email.

Before he joined the administration, Bradford had referred to Mark Zuckerberg, Facebook’s chief executive, as a “little arrogant self-hating Jew” and had called President Obama “Kenyan creampuff” on Twitter.

On the anniversary in 2016 of the opening of internment camps to detain Japanese-Americans during World War II, he said: “It was necessary.”

“I resigned because I reached the conclusion over the previous four months that the best way to serve the President, the USA, and Indian Country would be from a position beyond the constraints I experienced,” Bradford told The Washington Post by email following his resignation. “I look forward to helping make America great again in another role.”

In June, when The Post reported on the now deleted tweets, Bradford apologized for the messages. “As a minority and member of the Jewish faith, I sincerely apologize for my disrespectful and offensive comments,” he wrote in an email. “These comments are inexcusable and I do not stand by them. Now, as a public servant, I hold myself to a higher standard, and I will work every day to better the lives of all Americans.”

Earlier this week, CNN reported on an online account that appeared to belong to Bradford that called Obama “the son of a fourth-rate p&*n actress.” In response, Bradford claimed that he had been the victim of “hacking, and impostors in social media.”

Andrew Kaczynski, one of the CNN reporters who wrote that story, said on Twitter he had asked Bradford for comment on a follow-up story Thursday morning before his resignation.

“I don’t wish ill will on anyone,” wrote Chris Lu, formerly a deputy labor secretary and co-chair of the White House Initiative on Asian Americans and Pacific Islanders under Obama, in an email. “But the fact that Mr. Bradford was ​able to get a high-level government position and remain as long as he did is troubling.”

Controversy has followed Bradford long before his appointment in the Energy Department. In 2015, he resigned from another job with the federal government — as an assistant law professor at West Point — after it was discovered he wrote an academic paper in which he called for legal scholars “sympathetic to Islamist aims” to be imprisoned or “attacked.” He also suggested journalists who talk to those scholars could also be targeted.

At the time, Bradford told The Post that he left “because I did not want the cadets or U.S. Military Academy to be exposed to any increased risk as a result of the backlash over my article, and I did not wish the institution to be burdened by this or by any other distractions.”

A decade before that, in 2005, Inside Higher Ed, a publication that covers colleges and university, found evidence that Bradford exaggerated his military experience while teaching law at Indiana University in Indianapolis. Bradford denied that charge, too.

In June, five members of the Senate Democratic Caucus asked Energy Secretary Rick Perry to fire Bradford for the “divisive rhetoric” in his tweets. This month, one of those senators, Ron Wyden (D-Ore.), sent letters to the Energy and Justice departments asking them to investigate Bradford’s hacking claims.

“Mr. Bradford was clearly unfit to serve in the federal government,” Wyden, who as a member of the Senate Committee on Energy and Natural Resources oversees the Energy Department, said following Bradford’s departure. “From misrepresenting his military record, to his loathsome public comments about women, Muslims, Jews and Japanese-Americans, to his total lack of experience on energy issues, he was an unacceptable choice from the start.”