The FBI has arrested three suspected members of a neo-Nazi group who built a machine gun and hoped to start a US race war, just days before a planned gun-rights rally in Virginia that was expected to draw thousands of people, officials said on Thursday.

The three men – Brian Lemley, a former cavalry scout in the US army and Patrik Mathews, a former combat engineer in the Canadian army reserve, and suspected white supremacist William Bilbrough – appeared in court on Thursday.

Mathews went missing in August, after the Winnipeg Free Press reported that he was a recruiter for a neo-Nazi group known as The Base. Days later, he was discharged from the military over the allegations.

Their court appearance came the day after the Virginia governor, Ralph Northam, declared a state of emergency banning any weapons around the grounds of the state capitol in Richmond, saying investigators had seen groups making threats of violence.

Lemley and Mathews stood calmly before the judge in US district court in Greenbelt, Maryland, on Thursday, Lemley wearing a T-shirt and pyjama pants and Mathews wearing camouflage pants and sporting a bushy blond beard. Both answered “yes” and “no” when the judge asked if they understood the charges against them, which include transporting a firearm with intent to commit an offense, and if they were under the influence of drugs or alcohol.

The judge set their detention hearings for Wednesday.

The FBI and the Department of Homeland Security have been sharply criticized for not focusing enough on the threat of far-right extremism following a spate of attacks on synagogues and a 2017 white-supremacist rally in Charlottesville, Virginia. Heads of both of those agencies have said in recent months that they were taking the threat more seriously.

Several thousand gun-rights supporters are planning a large rally in Richmond, Virginia’s capital, on Monday in response to the newly Democratic-controlled state legislature’s push to stiffen gun laws.

Virginia, where Democrats took control of the legislature by promising stronger gun laws, has become the latest focal point for the contentious American debate around the right to bear arms. Many gun-rights groups contend the US constitution guarantees their ability to possess any firearm. Those opposed say gun laws would help lessen the number of people killed by guns each year.

The three men are accused of interstate commerce of weapons, harboring illegal aliens, an alien in possession of a firearm and ammunition, and aiding and abetting.

The FBI also said in the court filing that the men had attempted to manufacture DMT, a chemical resembling the structure of psilocybin in psychedelic mushrooms and an illegal drug under federal law.

While federal authorities can bring criminal terrorism charges against those suspected of working on behalf of foreign extremist groups like al-Qaida, they lack those tools when pursuing those affiliated with domestic extremist groups, whose views are protected by the free-speech clause of the US constitution.

The FBI said in the court filing that the three are members of The Base. The FBI said in the court document that it had monitored encrypted chats among the group’s members, in which they discussed creating a white ethno-state and carrying out acts of violence against minorities.

The men were in possession of what appeared to be a fully automatic rifle, according to an FBI agent who watched the men fire the weapon at a gun range.

Shortly after firing the weapon on 2 January at a Maryland gun range, Lemley told Mathews, “Oh, oops, it looks like I accidentally made a machine gun,” according to the court document.

Lemley and Mathews lived together in Delaware, while Bilbrough resided in Maryland. Mathews illegally crossed over the border into the United States in August, according to the court document.