WASHINGTON ― Sebastian Gorka, a controversial adviser to President Donald Trump, is leaving the White House after months of criticism about his ties to far-right foreign political groups and his description of Islam as an inherently violent religion.

The Federalist published a copy of his resignation letter Friday. But after the letter was made public, a White House official implied that Gorka was forced to step down. “Sebastian Gorka did not resign, but I can confirm he no longer works at the White House,” the official said late Friday.

In the letter, Gorka appears to allude to the recent departure of several of his allies in the White House, most notably Trump’s former chief strategist, Steve Bannon.

“[G]iven recent events, it is clear to me that forces that do not support the MAGA promise are ― for now ― ascendant within the White House,” Gorka wrote in the letter obtained by the Federalist. “As a result, the best and most effective way I can support you, Mr. President, is from outside the People’s House.”

Gorka singled out Trump’s recently announced Afghanistan policy for criticism. He was particularly concerned that Trump’s speech did not include the phrases “radical Islam” or “radical Islamic terrorism,” he wrote in the letter.

Gorka’s official title at the White House was deputy assistant to the president, but it was never clear what his actual duties entailed. He regularly appeared on television as a vociferous defender of Trump’s national security agenda and worldview. But he reportedly wasn’t able to get security clearance that would have allowed him to sit in on the most high-level national security meetings or read classified information.

Gorka was closely aligned with Bannon, who left the administration earlier this month. Bannon has since returned to the far-right media outlet Breitbart News, which Gorka wrote for before joining the administration.

Like Bannon, Gorka expressed a dark view of Islam. The FBI used to employ Gorka to teach courses on terrorism, but the Daily Beast reported that the agency stopped working with him after he told students that all Muslims adhere to Sharia law and will eventually be radicalized.

“Regrettably, outside of yourself, the individuals who most embodied and represented the policies that will ‘Make America Great Again,’ have been internally countered, systematically removed, or undermined in recent months. This was made patently obvious as I read the text of your speech on Afghanistan this week,” Gorka continued in his resignation letter. “The fact that those who drafted and approved the speech removed any mention of Radical Islam or radical Islamic terrorism proves that a crucial element of your presidential campaign has been lost.”

Before joining the White House, Gorka was an obscure far-right fringe character. He promoted himself as an authority on counterterrorism, but national security experts mocked his credentials and refuted his characterization of Islam as a path toward violent radicalism. Most terrorism experts and academic say terrorists become radicalized through a combination of factors ― poverty, poor governance, lack of opportunity, foreign intervention and religious ideology, for example ― but Gorka argues that Islam is the driving force. He does not speak Arabic and has spent little time in the Middle East.

Gorka joined the Trump campaign in 2015 as a paid adviser. Since then, he has celebrated Trump’s frequent warnings about the threat of “radical Islamic terrorism” and accused the Obama administration of being hamstrung by political correctness. When Trump won the election last year, Gorka told Fox News that “the alpha males are back.”

Alex Wong via Getty Images Sebastian Gorka participates in a discussion during the Conservative Political Action Conference on Feb. 24.

Gorka wore a medal signifying membership in the Vitezi Rend, a Hungarian group that collaborated with the Nazis in World War II, when he attended Trump’s inaugural ball in January, LobeLog reported. Members of the group told the Forward that Gorka is a member of the Vitezi Rend, but Gorka has said the medal belonged to his father and that he wears it in memory of his father’s anti-communist efforts in Hungary.

The Vitezi Rend debacle prompted reporters to dive into Gorka’s past. Gorka, who was born in Britain to Hungarian parents, founded a political party in Hungary in 2007. The party’s members were politicians who had previously belonged to Jobbik, a party that has espoused anti-immigration, anti-Semitic and homophobic positions, the Forward reported. Gorka expressed support for an anti-Semitic Hungarian militia called the Magyar Garda in August 2007, the Forward found. The European Court of Human Rights accused the group of working to create “an essentially racist legal order.”

People who worked with Gorka at the National Defense University and Marine Corps University over the past decade say they don’t recall him making negative comments about Jewish people. But some remember Gorka hinting at an anti-Islam worldview. He once told David Ucko, who worked at the NDU at the time, that devout Muslims are more inclined to celebrate violence than Christian because the religion was founded by a warrior, Ucko told HuffPost.

Talk of Gorka stepping down began as early as May, after news reports surfaced that detailed his ties to Nazi sympathizers and far-right Hungarian political groups. But Trump and Bannon personally intervened to save his job, the Daily Beast reported. In the following weeks, national security adviser H.R. McMaster pushed out several White House staffers who shared Gorka’s extremist ideology.

But even as Gorka’s like-minded allies left the White House, he appeared on television, offering bombastic defenses of his boss and berating the media for criticizing the president. When Trump failed to condemn the bombing of a mosque in Minnesota, Gorka suggested the incident could be a false flag attack perpetrated by the president’s political opponents. When Trump went off script and warned of “fire and fury” against North Korea, Gorka praised the president’s show of strength ― even as the secretary of state and secretary of defense took a more restrained approach. Days before a deadly white supremacist rally in Charlottesville, Virginia, Gorka reprimanded the media for reporting on the violent extremism threat posed by white nationalists.

Nick Visser contributed to this report.