As the police returned to Justice Park, though, the crowd followed, and “there were a number of incidents, including the use of pepper spray by the crowd,” Miriam Dickler, a city spokeswoman, said in a statement.
At one point, the police again ordered the crowd to disperse, but the protesters remained entrenched. Ms. Dickler said the Virginia State Police then released three canisters of tear gas.
“The crowd immediately dispersed,” she said.
Over the course of the day, Ms. Dickler said that at least 23 people had been arrested, and that at least three people had been taken to a hospital — two for “heat-related issues” and one for an “alcohol-related issue.”
In an email, Ms. Dickler said she could not “speak to the affiliations” of those who were arrested.
The rally, and the response to it, put the city on edge, and upset some residents who had hoped the event would end without any problems.
“We were just standing there, peaceful, on the sidewalk,” said Candice Maupin, a city resident and one of the counterprotesters. “We heard this boom, and then this green smoke, and our eyes started burning.”
City officials and church leaders had asked residents to stay away from the rally. Concerts and other events were planned to encourage residents to spend the day elsewhere.
“It’s become a game,” said Bob Fenwick, a city councilman.
Indeed, Charlottesville has become a flash point in a debate about how cities across the South should reconcile themselves with their past and, specifically, with the Civil War.
The Charlottesville City Council voted narrowly in April to sell the statue of Lee. But in May, a circuit court judge in the city issued a six-month injunction to halt the removal of the statue after a collection of individuals and groups — including the Virginia chapter of the Sons of Confederate Veterans — filed a lawsuit against the city.
Demonstrators led by Richard B. Spencer, a noted white supremacist, marched here in May to protest the city’s plan to remove the statue. Mr. Spencer posted pictures and videos from the gathering that showed demonstrators holding Confederate battle flags and a banner proclaiming, “We will not be replaced.”
“People should be able to respect our heritage,” said Amanda Barker, who identified herself on Saturday as a member of the Ku Klux Klan. She added that she was underwhelmed by the number of people who had turned out to oppose the rally.
Counterprotesters, who chanted “go home,” “black lives matter” and a variety of profanity-laced insults, said it was important for them to confront the Klan because simply ignoring white-supremacist viewpoints could allow such views to proliferate.
Ms. Dickler, the city spokeswoman, said another rally by white nationalists has been planned for Aug. 12.