A former State Department staffer with a top-secret security clearance betrayed his oath of office when he joined the Capitol mob that attempted to subvert the electoral process on Jan. 6, a federal magistrate judge said Tuesday.

Quoting that oath, which requires federal workers and appointees to “defend the Constitution of the United States against all enemies, foreign and domestic,” Judge Zia M. Faruqui said that on Jan. 6, domestic enemies were striking “directly at the heart of our democracy” and Federico Klein “switched sides.”

Faruqui ordered Klein, 42, detained until his trial on charges of assaulting police, trespassing and obstructing Congress. Klein worked on Donald Trump’s 2016 presidential campaign and then served under him as a political appointee; he resigned the day before President Biden took office. He served in the Marine Reserves from 2004 to 2012, including a seven-month tour in Iraq. He has a top-secret security clearance that was renewed in 2019.

Stanley Woodward, his attorney, argued that Klein’s military and government service should weigh in favor of release. Although he did not concede that the Trump appointee was the man seen in video from the riot, Woodward said that the event was “total chaos” and that an individual might not have been able to hear or follow police orders.

Prosecutors said Klein was not a hapless member of the crowd but a leader in the charge to storm the building. Assistant U.S. Attorney Jocelyn Bond said Klein fought officers in “hand-to-hand combat” for half an hour, while calling for “fresh people” to help take the building.

“He is persistent; he is unrelenting,” Bond said. Only when police deployed chemical spray, she said, was Klein “physically unable to keep fighting.”

His service only makes his behavior more dangerous, she argued: “This was not a youthful indiscretion or somebody who didn’t know better,” but someone trusted with classified information who “turned around and essentially attacked his own government.”

Faruqui agreed that Klein “was literally directing people” to confront the officers.

Dismissing Woodward’s arguments about the chaotic nature of the event, the judge said there was no confusion among the rioters about their purpose: “This was one group of people that were uniformly trying to do one thing, which was to stop the process of democracy.”