The FBI has arrested three alleged members of a white-supremacist group on federal gun and alien-harboring charges amid growing concerns about safety surrounding planned gun rights protests in Virginia’s capital next week.

The charges announced Thursday grew from an investigation of a collection of online extremists who refer to themselves as “the Base,” which is the English translation of “al-Qaeda.” According to experts who track hate groups, its members promote racist views and seek to unite different hate groups in preparation for a race war.

Officials said Brian Mark Lemley Jr., 33, and William Bilbrough IV, 19, both of Maryland, were charged with transporting an alien and conspiring to harbor an alien. Lemley is also charged with transporting a machine gun. Also charged is Patrik Mathews, 27, who has been living in Newark, Del. He is accused of transporting a firearm and ammunition with the intent to commit a felony.

Federal officials moved on the trio partly out of concerns they might engage in violence at a gun rights rally planned for Monday in Richmond, according to people familiar with the investigation. The Virginia General Assembly’s new Democratic majority is advancing four bills that seek to restrict some people’s access to firearms.

“Lemley, Mathews, and Bilbrough are members of a white supremacist organization named ‘The Base,’ ” the complaint charges. “Within The Base’s encrypted chat rooms, members have discussed, among other things, recruitment, creating a white ethno-state, committing acts of violence against minority communities (including African-Americans and Jewish-Americans), the organization’s military-style training camps, and ways to make improvised explosive devices.”

Lemley previously served as an Army scout, while Mathews was a combat engineer in the Canadian army reserve, according to court papers.

Mathews went missing in Canada in August, and U.S. officials say that after he slipped across the border, Lemley and Bilbrough met up with him in Michigan and brought him to Maryland and Delaware.

The court papers charge that Lemley and Mathews used gun parts “to make a functioning assault rifle.”

On Jan. 2, an FBI agent watched as Lemley took the weapon to a gun range in Maryland “and heard what appeared to be more than one bullet being fired at a time,” according to the documents.

After returning from the gun range, Lemley allegedly told Mathews, “Oops, it looks like I accidentally made a machine gun,” and noted that they would be in trouble if the Bureau of Alcohol, Tobacco, Firearms and Explosives found out about the weapon.

In advance of Monday’s gun rights protests in Richmond, Virginia Gov. Ralph Northam (D) has declared a state of emergency, temporarily banning weapons from the Capitol grounds, citing “threats of armed confrontation and assault on our Capitol.”

The governor’s declaration means that from Friday evening until Tuesday night, firearms, sticks, bats, chains and other weapons will be prohibited on Capitol Square and throughout the Capitol complex.

Monday is the state’s traditional citizen lobbying day, and gun rights groups are organizing a large demonstration to oppose the proposed legislation.

The rally has drawn interest from militias and extremist groups across the country, raising security concerns in Richmond.

Northam has asked “nonessential” state employees not to come to work Monday, a state holiday during which legislative staffers would normally be on duty, since the legislature is in session.

FBI Director Christopher A. Wray warned Congress in the fall that American neo-Nazis seem increasingly to be communicating with like-minded, violent racists overseas, but he cautioned that those links so far appear more inspirational than organizational.

“We are starting to see racially motivated violent extremists connecting with like-minded individuals online, certainly, and in some instances we have seen people travel overseas to train,” Wray said.

In September, the FBI arrested an Army soldier who had allegedly hoped to join a militia in Ukraine, following the example of another former soldier who had done so.

Wray said that violent extremists in the United States still by and large lack organizational structure and direction but that there are now individual terrorism suspects who travel overseas to get training — behavior similar to that of Americans inspired by the Islamic State or other groups.

“We have seen some connection between U.S.-based neo-Nazis and overseas analogues,” Wray said. “Probably a more prevalent phenomenon that we see right now is racially motivated violent extremists who are inspired by what they see overseas.”