This video provided by the ACLU appears to show a man firing at counterprotesters during a white nationalist rally in Charlottesville, Va., Aug. 12. (ACLU of Virginia)

Arriving in Charlottesville for a rally planned by white nationalists earlier this month, Virginia’s top homeland security official nodded to a nearby group of men clad in camouflage and armed with semiautomatic rifles, believing they were soldiers in the state’s National Guard.

Then he did a double take.

“They’re not ours, are they?” said the official, Secretary of Public Safety Brian Moran, who described the exchange in an interview. “No, sir,” came a reply from his deputy in the passenger seat. “I don’t think they’re with us.”

The presence of the homegrown militia was just one in a series of unanticipated developments in Charlottesville for state and local law enforcement leaders who had planned for weeks for the Aug. 12 showdown between white nationalists and counterprotesters. Despite warnings to the city manager and police chief that a more aggressive approach was needed, including an appeal from Gov. Terry McAuliffe, the local police in charge temporarily lost control of the city as people brawled on the streets, leaving one dead.

And though a torch-lit march the night before ended with white nationalists attacking college students, city officials said police stuck to a tactical plan that included little-to-no visible buffer zone between armed white nationalists and their armed opponents.

Most dangerously, law enforcement experts say, officers initially deployed without adequate protective gear to break up fighting and were not well positioned to keep the peace. As fights erupted, police stayed back. They stood not between the two opposing groups but behind them and off to the sides. And when they cleared the park where rallygoers had gathered near a statue of Confederate Gen. Robert E. Lee, police flushed many of them directly onto the same street where counterprotesters were gathered, according to witnesses and video.

The area became a flashpoint, and video that surfaced Friday appears to show a white nationalist fire a handgun after leaving the park. By the end of the day, two police officers were killed in a helicopter crash.

The police tactics on the ground and approach mystified some law enforcement veterans and experts, including former Charlottesville police chief Timothy J. Longo, now a lecturer at the University of Virginia who teaches about the use of force by police.

“How do you allow two completely divergent and armed groups to come in contact with one another, knowing full well for weeks in advance that there were warnings of violence?” Longo asked. “In the current climate, this has all the earmarks of something that will happen again, and certainly every city should be looking at what happened to learn a lesson.”

In a confidential memo Thursday to City Manager Maurice Jones, the City Council demanded an explanation for the “apparent unwillingness of officers to directly intervene during overt assaults captured in many videos.”

Charlottesville Police Chief Al Thomas, who was in charge that day, declined to be interviewed but said in a statement to The Washington Post that his office “realized the potential for serious violence” and worked closely with the state police.

A vehicle plows into a group of counterprotesters in Charlottesville after a white nationalist rally on Aug. 12, 2017. One woman died, and an Ohio man faces charges. (Ryan M. Kelly/The Daily Progress)

“We employed the Unified Command approach every step of the way that morning, which ultimately limited the number of injuries, arrests, and incidents within and immediately surrounding Emancipation Park,” he wrote. “There was never a ‘stand down’ order issued. Instead, there were processes to initiate and multiple things going on all at the same time, that participants and the media would not have seen taking place.”

Mayor Mike Signer and some council members, however, say they were locked out of the planning process. In Charlottesville, as in many municipalities in Virginia, the police chief reports to the city manager rather than to the mayor, and the mayor does not have the executive powers commonly held in many states.

On Friday, the council announced that Timothy Heaphy, former U.S. attorney for the Western District of Virginia, would lead an independent review of the events of Aug. 12.

Court documents, internal city memos, emails and text messages show Charlottesville city leaders were often at odds in key respects in the weeks leading up to the rally. Signer led a push by council members as early as July 13 to relocate the rally outside of the city’s downtown core. In the confidential memo, the council faulted Jones for failing to act quickly to relocate the protest and for his handling of the event overall.

Jones denied that he was slow to pursue the idea of moving the rally. The city ultimately decided to revoke the rally permit on Aug. 7, a decision organizers challenged successfully in federal court, with the backing of the American Civil Liberties Union.

Signer wrote on Facebook that, before the rally, he asked Chief Thomas what he could do to help.

The chief replied: “Stay out of my way.”

Requests from McAuliffe

A month earlier, Charlottesville and State Police had faced criticism for being too aggressive in their response to a Ku Klux Klan gathering. About three dozen Klan members, surrounded by a phalanx of state and local officers, demonstrated in another downtown park. The police, wearing riot gear, created a buffer zone between the Klan and approximately 1,000 protesters.

There were no reports of violence until the rally ended and straggling protesters confronted police, who then used tear gas to break up the crowd.

Charlottesville council members called for an investigation and public report.

The review never came. In its memo to Jones last week, the council said the failure to produce a report was “a significant problem given the need for us to learn lessons from July 8 for August 12.”

As Charlottesville was preparing for the Unite the Right rally this month, the governor called Signer on Aug. 2. He asked that Charlottesville shorten the length of the permitted rally and prohibit guns. He recommended that the city not allow backpacks into the protest area, citing warnings — including from the FBI — that bags could be used to conceal weapon or improvised explosive devices.

McAuliffe also wanted attendees to park outside the city and to be bused to downtown. He said he worried officers would not be able to maintain public safety when white nationalists and counterprotesters disbanded and headed back to their cars.

None of these restrictions were put into place, Jones acknowledged. He said that the city did not believe it had the authority to ban backpacks and that the busing plan was unrealistic because it would require cooperation from the protesters, who he said “did not follow the previously agreed-to security plan.”

Under Virginia state law, Thomas, the police chief, was in charge of handling the rally. But Moran and Col. W. Steven Flaherty, superintendent of the state police, had separately made preparations. More than 600 troopers in Virginia were in Charlottesville or on their way. On the governor’s order, the National Guard had also moved a planned weekend training exercise for a military police unit from Manassas, more than 80 miles away, to the armory just outside Charlottesville.

As the rally date approached, however, confusion grew about the details.

The final location was not determined until Friday evening, when a federal judge ruled that it could proceed at Emancipation Park. The rally’s organizers say they were given conflicting information from law enforcement about which routes to take to the park and what time they could arrive.

Thomas has said police attempted to keep the two sides separate but that rallygoers “decided to change their plan and enter the park in different locations.”

The rally was scheduled to start at noon Saturday. But organizers said in court records that police instead decided to open the grounds at 6 a.m. and reversed an earlier pledge to escort them into the park, a claim the city did not dispute in court documents.

Online message boards for white nationalists soon filled up with talk of getting to the park first to hold ground. The brew of conflicting information and confusion set the stage for a Saturday rally that became one of the most violent white-nationalist protests in decades.

‘A tinder box’

When Moran left for Charlottesville the day before the protests, he joked with the governor about needing a bulletproof vest. The next day, he texted McAuliffe pictures of the heavily armed militia.

“I’m going to need that vest,” he wrote.

At 8:30 a.m., the event’s organizer, Jason Kessler, arrived. His group encountered barricades blocking a rear entrance to the park that police had said the rallygoers were supposed to use, he said. They took side streets around to the front of the park, and there encountered a gantlet of counterprotesters to reach the park entrance, he said.

“They created a tinder box,” Kessler said. “Police didn’t provide the safe passage we expected, and the counterprotesters, they didn’t get a fair shake, either — an area where they could safely express their views without fear of harm.”

Chuck Wexler, executive director of the Police Executive Research Forum, which trains law enforcement officers on best practices, said that Charlottesville appeared not to follow fundamentals for how to deal with events involving confrontational groups.

“One of the most significant things you can do when you have two kinds of volatile groups is meet with them beforehand and establish strong lines of communications,” Wexler said. “You want to establish the rules of engagement, make sure they know their rights to express their opinions and keep them separate from the counterdemonstrators. Above all else, be a visible presence between the two, because otherwise you are inviting problems.”

By 10 a.m., Market Street was filled. White nationalists were on a collision course with counterprotesters, marching directly past — or through — them on their way to the park. There was pushing and shoving. Many of the white nationalists wore helmets and protective eye goggles and carried shields, clubs and guns. Some counterprotesters, including a smaller number of antifa, or self-described antifascists, also wore helmets and goggles and carried makeshift shields and sticks.

“We were starting to feel then obviously that things were starting to get to the point where we needed to accelerate our preparations,” Moran said. “I ran over to the command center on the Wells Fargo’s 6th floor and got a good view. … There was sporadic fighting. They’d fight, they’d split up. But the groups were starting to amass.”

Before 10:30 a.m., council members received an email from Jones, the city manager, warning that conditions were deteriorating and authorities probably would have to clear the park.

Soon, bottles and other objects began flying back and forth between rallygoers in the park and counterprotesters in the street. The police in the park and along its sides remained in place. None wore riot gear.

A few minutes later came the first extended brawl. A line of marchers with shields and clubs plowed through a line of counterprotesters. Both sides sprayed chemical irritants. Punches were thrown and bodies kicked to the ground.

The police did not intervene.

“The worst part is that people got hurt, and the police stood by and didn’t do a g------ thing,” David Copper, 70, who was there to protest the white nationalists, told The Post that day.

Jones, the city manager, said, “We were hoping for a peaceful demonstration but as the tensions rose, we transitioned our officers into riot gear.”

By 11:15 a.m., commanders watching from the bank decided the only safe way to address the melee was to declare an unlawful assembly. At 11:22, they gave the white nationalists and counterprotesters 11 minutes to disperse.

Police forced rallygoers into the street filled with protesters. At one exit, a protester stood waiting with an aerosol can and a lighter that he ignited in a makeshift flame thrower. An ACLU video, first reported by the New York Times, appears to show one of the rallygoers pointing and shooting a handgun toward the protester with the flame thrower.

Matthew Heimbach, the leader of the white-nationalist Traditionalist Workers Party, said he asked an officer whether police were going to clear the street. “The cop said, ‘It’s not my job,’ ” Heimbach said. “It was really unclear what the rules were. Or if there even were rules. We had no idea.”

Council member Bob Fenwick, however, saw it differently. Most rallygoers headed out of the park peacefully, with some opposing groups standing a few feet from one another, he said. “It was surreal, like a street festival, but one where every so often a fistfight would break out. But I thought the police had done a good job — if they had been down in the middle earlier, they would have been the target.”

The National Guard took control of the park after it was cleared, but violent clashes continued to flare in the streets. Police say they swarmed from one hotspot to another. More than an hour passed before they regained control of downtown.

In that time, white men beat a black man with poles and sticks in the entrance of a major downtown parking garage, leading to one of the day’s most searing images. The beating continued without any sign of police intervention, video shows.

A frantic appeal came from Signer before 2 p.m. asking for police protection at the city’s only synagogue — a location the mayor had raised alarms about in the days before the rally — after he was shown a series of tweets connected to a white-nationalist site. “It’s time to torch these jewish monsters lets go 3 pm.” Another replied “We must not slacken! SIEG HEIL.”

“Address?” replied Moran in a text. “On it.”

By 1 p.m. Saturday, Emancipation Park was cleared of protesters and controlled by the National Guard.

It appeared the city had dodged the worst. Then Moran suddenly heard an alert inside the command center: pedestrians struck. He looked up at a screen showing a live video feed from a helicopter hovering overhead.

“We saw the video and knew immediately what had occurred,” he said.

Police had put roadblocks around downtown to keep cars away from pedestrians. But that did not stop a driver from speeding into a crowd, killing Heather Heyer and injuring at least 19 others. The man behind the wheel was later identified as James Alex Fields of Ohio, 20, who faces charges including second-degree murder.

Moran picked up the phone and called the governor.

“You’re about to see some very horrible video,” Moran said. “The public is going to see some horrible video.”

Arelis R. Hernández and Michael E. Miller contributed to this report.