A tribute in Charlottesville to Heather Heyer and those hurt in the violence during protests. (Michael Reynolds/European Pressphoto Agency)

IN THE days and weeks leading up to the deadly racist violence in Charlottesville on Aug. 12, Virginia state and local law enforcement received a deluge of intelligence about who was coming and what to expect. They responded with the biggest deployment of police and state troopers the state had seen in decades — in the vicinity of 700 personnel, perhaps a third of them in riot gear. Still, things went murderously wrong. Why?

In this case, Monday-morning quarterbacking is critical, and it’s essential that the authorities, who themselves are preparing internal reports, get it right. The failure to prevent the tragedy in Charlottesville must not be repeated elsewhere on a larger scale, even as Americans see clearly that the white supremacists, Ku Klux Klansmen and neo-Nazis who descended on the city bear the guilt for what happened.

First, in trying to strike the undeniably tricky balance between ensuring public safety and enabling protesters to exercise their constitutional rights, the authorities tilted too far away from public safety. Despite the massive law enforcement presence, most of the real police muscle — so-called tactical teams fully equipped with anti-riot gear — was kept in reserve, some blocks away from the protest’s epicenter.

That left regular troopers and police, lacking shields and full body armor, on the front lines, reluctant to wade into the brawls that spread through downtown streets and escalated as the morning went on. Hence the widespread reports and images of police standing idle as melees erupted around them. Given that authorities had anticipated the violent and hateful tendencies of the “Unite the Right” marchers, riot-gear-equipped officers could have, and should have, made an earlier show of force.

Second, the unified command structure in Charlottesville left city authorities in charge — illogically, when state troopers (and the Virginia National Guard, which was ultimately called out) outnumbered city police by at least 4 to 1. When widespread violence is a threat, a sedate college town of fewer than 50,000 residents is not equipped to take the lead.

Third, local authorities erred not only by failing to block streets near the demonstration, which allowed a car allegedly driven by a neo-Nazi from Ohio to ram a crowd of counterprotesters, killing 32-year-old paralegal Heather Heyer, but also by allowing protesters and counterprotesters to carry sticks, clubs and other supposedly nonlethal weapons. In addition to Ms. Heyer’s tragic death, at least 30 people were injured, many of them seriously.

Finally, state lawmakers must reassess gun laws that allow anyone with a concealed-carry permit to also openly carry military-style assault weapons virtually wherever they like, and others to openly carry legally acquired handguns. Local officials facing the potential for violent confrontation between rival groups, or between protesters and police, are impotent to minimize the potential for mass casualties in such a situation; it’s a wonder that gunfire didn’t erupt amid the violence in Charlottesville.

Yes, things could have been much worse. With better planning and execution, however, the tragedy in Charlottesville might have been contained or avoided.