After events in Charlottesville, Va., last weekend showed how much violence white nationalist rallies could provoke, police chiefs from Richmond, Va., to Boston were taking steps to avoid a repeat of a situation in which the police appeared to have little control of the crowd.

Texas A&M University canceled a “white lives matter” rally at which Richard Spencer, a white supremacist leader, was to appear, citing safety concerns. Officials in Mountain View, Calif., where Google has its headquarters, were gearing up for one of several marches at the company’s offices around the country to protest the firing of a male employee who wrote a memo criticized as sexist.

Rallies like the one in Charlottesville, fueled by overt displays of racism, attended by members of self-described militias, and attracting counterprotesters, pose novel challenges: Many of the demonstrators are legally and openly carrying firearms, including semiautomatic weapons. And instead of protesters versus police, as has often been the case in recent years, the situation is civilian versus civilian, with some participants spoiling for a fight.

But to deal with these new circumstances, the police have few new tactics.

Crowd-control techniques are much the same, experts said, whether demonstrators are armed or not. A crucial technique is keeping opposing sides apart, which the police tried and failed to do in Charlottesville on Saturday. In the hours leading up to the planned rally, people fought in full view of police officers. On Monday, a man was charged with driving a car into a crowd of counterdemonstrators, killing a woman and injuring more than a dozen others. The actual rally was called off by the police after the governor declared a state of emergency.

“Charlottesville turned into a riot,” said Mayor Martin J. Walsh of Boston, where a free speech rally was thought to be planned for Saturday, although some of the details were murky. “Both sides were able to connect. In our city, we will do everything we can that those two sides never connect.”

Mayor Walsh said that Boston wanted to discourage the rally’s organizers from coming, and that William B. Evans, the police commissioner, was developing a plan to keep the rally and any counterdemonstrations separate. By late Monday, it appeared that some of the billed speakers were backing out.

But if there is a rally, unlike the authorities in Charlottesville, officials in Boston will probably not be forced to confront a large number of armed protesters because Massachusetts allows only those with a gun license to openly carry a firearm. In Virginia, no license is required for those over 18.

In South Carolina, where there were dozens of protests related to the removal of the Confederate battle flag from government buildings, firearms are prohibited from the State Capitol grounds. Leroy Smith, the state director of public safety, said that intense anger over such issues combined with the presence of firearms would have been a toxic mix.

“With the added element of open carry, it creates more of a challenge for law enforcement officers because usually when you see a weapon and that person is not a law enforcement officer, you know you need to defuse the situation,” he said.

Many urban police chiefs have opposed open-carry laws, even in states where people feel fiercely protective of their gun rights.

John Eterno, a former training instructor with the New York Police Department who now teaches at Molloy College, said the presence of weapons combined with the unexpectedly large crowds in Charlottesville might have thrown off that city’s planning. When people have the right to carry firearms, the police must balance caution with respect, he said. Officers can do little more than check the person’s demeanor for signs of aggression and monitor whether the firearm is properly holstered.

The Charlottesville police have faced a hailstorm of criticism from protesters and counterprotesters alike. Witnesses have said officers did little as violent confrontations unfolded in front of them.

On Monday, officials defended their response, noting the lack of property damage in the city, and the Virginia governor said little could have been done to prevent a driver from hitting pedestrians.

At a news conference on Monday afternoon, Al Thomas, the Charlottesville police chief, acknowledged that there were times when police officers were spread too thinly. “We had to actually send out forces to multiple locations to deal with a number of disturbances,” Chief Thomas said. He added: “It was certainly a challenge. We were spread thin once the groups dispersed.”

But he also noted a central problem with the strategy of keeping opponents away from each other: The police cannot always control who is going to go where. “We did make attempts to keep the two sides separate. However, we cannot control which side someone enters the park,” Chief Thomas said.

He said that there had been a plan to keep the Unite the Right rally separate from counterprotesters, but that few cooperated.

Virginia’s governor, Terry McAuliffe, cited a police estimate that 80 percent of the protesters and counterprotesters were armed, and that the militias, who described themselves as neutral peacekeepers, had arsenals superior to that of the police. But Chief Thomas denied that his officers were “intimidated by the firepower of the alt-right.”

Officers began the day in regular uniform. “Once the violence erupted, once the plan was altered, we had to quickly transition our officers into their protective gear,” Chief Thomas said.

Charlottesville had known that it would be ill prepared. The city, fearing that many more than the estimated 400 people would attend, said it would issue the permit only if the location were moved.

“Because Emancipation Park is a relatively confined space of just over one acre in a densely populated urban area with limited parking space, it is unable to accommodate safely even a peaceful crowd of this size,” the city manager, Maurice Jones, warned rally organizers in a letter on Aug. 7.

“The city’s law enforcement, fire and emergency medical personnel cannot adequately protect people in and around Emancipation Park due to the number of anticipated attendees trying to occupy such a small and confined space.”

The city wanted to move the protest to another park, but the American Civil Liberties Union successfully argued in federal court on behalf of Jason Kessler, the organizer of the event, that the city was retaliating against him because of the “content” of his speech, citing the fact that none of the counterprotesters’ permits were revoked. Thousands attended.

The leaders of the Unite the Right rally have pledged to return to Charlottesville.

This weekend, the mayor of Lexington, Ky., announced plans to try to take down two Confederate statues.

The chief of police in Lexington said he had already spoken with officials in Charlottesville for details on what worked and what had not.

“You’ll have people feeling passionate wanting to come in, but you’ll also have professional protesters who want to come in and fight. We’ll be prepared for them also,” said the chief, Mark Barnard.

But, he added, “You can have as much intelligence about the groups and their past behavior, you can have all planning and all the training, but you can’t predict what will go on.” Kentucky is an open-carry state.

He said he doubted the city would give permits to groups with opposing views to speak from the same location at the same time.

“You wouldn’t allow that,” he said. “You’d have to make a decision and have it at a different time. But it doesn’t mean the other side won’t show up.”