A former police officer accused of participating in the Jan. 6 riot at the Capitol will be held in jail until trial because he has been dangerously and illegally stockpiling guns, a federal judge ruled.

Thomas Robertson, 47, who was fired from his position in the Rocky Mount, Va., police department after being charged, was “radicalized” by his arrest and “cannot be safely released,” Judge Christopher R. Cooper of the U.S. District Court in Washington wrote in an order Wednesday.

Federal agents searched Robertson’s home last month and found a loaded assault rifle in his bedroom as well as four silencers, according to court records. They also went to a nearby gun shop, the government said, where the owner confirmed that Robertson had 34 guns waiting to be picked up and had handled the weapons. By the time he was arrested on July 7, according to prosecutors, Robertson had bought three more firearms.

A judge had released Robertson in January on charges in connection to the riot. But the court also required him to stay away from guns as a condition of his release. Prosecutors sought to detain him in late June after learning he had begun purchasing weapons. He has been jailed while awaiting Cooper’s ruling.

Robertson bought many of the firearms on the website Gun­Broker.com, according to prosecutors, where on June 10 he wrote: “I’ve said before. They are trying to teach us a lesson. They have. But its definitely not the intended lesson. I have learned that if you peacefully protest than you will be arrested, fired, be put on a no fly list. . . . I have learned very well that if you dip your toe into the Rubicon . . . cross it. Cross it hard and violent and play for all the marbles.”

Robertson argued that because he had most of the guns sent to a store, he had not personally transported or possessed them — an argument Cooper found unpersuasive. The judge was also unmoved by Robertson’s assertion that the guns were too old to be dangerous, saying it was simply inaccurate.

“Robertson has expressed remorselessness and endorsed future political violence,” Cooper wrote in his order. “Coincidentally or not, Robertson has also embarked on a remarkable shopping spree for high-powered assault weapons.”

Robertson’s son testified last week that one of the guns found in the home during the search belonged to him, not his father. Prosecutor Elizabeth Aloi said in court that contradicted his previous statements to law enforcement and might put him in legal jeopardy.

Aloi also said Robertson will probably face a new charge of transporting weapons while under felony indictment, either in D.C. or Virginia federal court. She noted that Robertson had already been warned about firearms in his home more than once, and that agents also found in his home a partially assembled pipe bomb. Robertson said the explosive device was a training tool he used as a police officer.

Cooper did not weigh in on that issue or the credibility of Robertson’s son, finding that the many guns he had bought and the firearms found in the home were enough to revoke his release.

“The undisputed facts demonstrate a concrete risk that Robertson might participate in or provide material support to acts of ideologically motivated violence if released at this time,” he wrote.

Robertson has admitted to attending the Capitol rally turned riot with another Rocky Mount officer. Both are accused of trespassing, disorderly conduct and obstructing an official proceeding.

Not long before Robertson was ordered on Wednesday to stay in jail, another Virginia law enforcement and military veteran was arrested and accused of participating in the assault on Congress. Prosecutors said James Davis, 45, of King George, Va., identified himself as a member of the Proud Boys before charging officers with a large pole.

“I fought for this country,” he said while pushing into the officers, according to the court record. “I’m a military police.”

An attorney for Davis did not immediately return a request for comment.