A so-called "free speech" rally by far-right groups had been scheduled to run until 2 pm (1800 GMT), but a half-hour before that police escorted its participants -- whose numbers appeared to be in the dozens -- to safety past a throng of anti-racism protesters.
Officials estimated turnout of about 40,000 demonstrators. Authorities said there were 27 arrests, mostly for assault and battery against the police, and disorderly conduct.
Aerial photos showed counter-protesters filling one of Boston's main streets for several blocks, in a huge outpouring of anti-racist sentiment in this strongly Democratic northeastern city.
While Boston saw no repeat of the violence that erupted last weekend in Charlottesville, Virginia, isolated scuffles between police and protesters prompted President Donald Trump to weigh in, with a tweet intoning against the "many anti-police agitators in Boston."
But as protesters began departing central Boston without major incident later Saturday, he followed up with a more positive tone.
"I want to applaud the many protestors in Boston who are speaking out against bigotry and hate," he tweeted.
"Our country will soon come together as one!"
Boston Police Commissioner William Evans told a press conference that while there were people "who came here to cause problems," authorities were able to maintain order and keep the two sides apart. He credited a unit specially trained for crowd control.
"I thought they did a good job of moving that crowd," Evans said. "Sometimes it doesn't look pretty, but that's what they're trained for."
The demonstration was held at a time of anguished national debate over racial relations, which was fanned when Trump defended some participants in last week's white nationalist and neo-Nazi rally in Virginia as "very fine people."
Trump's daughter Ivanka, who is Jewish, tweeted Saturday night: "It was beautiful to see thousands of people across the USA come together today to peacefully denounce bigotry, racism & anti-Semitism. We must continue to come together, united as Americans!"
Thousands of counter-protesters had convened in two groups before the main rally in Boston, chanting "No Nazis, no KKK, no fascists in the USA!" One man held a sign that read, "Stop pretending your racism is patriotism," and a woman's sign said, "Muslims welcome, racists out."
"It's time to do something," said Katie Zipps, who traveled from Malden, north of Boston, for the counter-demonstrations, organized by an amalgam of mostly left-leaning groups.
"We are out here to add an extra body to add to the numbers of those who resist."
Some local restaurants promised to donate their proceeds from Saturday to left-leaning groups, and others refused to serve the white nationalists, with one posting a sign that said: "Hope you Nazis packed a lunch."
Authorities in Boston had protectively ordered a strict ban on weapons in the rally area, and ordered garbage trucks and concrete barriers placed around the venue to prevent vehicles from entering.
According to an AFP photographer at the scene, police in riot gear prevented counter-protesters from reaching the venue of the white nationalist rally -- leading some to accuse police of defending "Nazis."
Crowds booed or harassed "free speech" demonstrators as they walked to or from the venue, while Boston police tweeted that rocks had been thrown at its officers.
A young woman was killed last weekend when an avowed white supremacist rammed his car into a group of counter-protesters in Charlottesville -- and President Trump's muted response to the violence has plunged his embattled administration deeper into disarray.
Despite the skirmishes Saturday, Boston Mayor Marty Walsh -- clearly relieved that the protests concluded with no injuries or substantial property damage reported -- had words of praise at day's end for the city's police, and even for the protesters.
"I want to thank all the people that came out today," the Democratic mayor said at the press conference.
"I want to thank all the people that came out to share that message of love, not hate. To fight back on racism. To fight back on anti-Semitism. To fight back on the white supremacists that were coming to our city -- the Nazis coming to our city," he said.
The protest was one of several scheduled to take place across the United States this weekend.
An evening demonstration in Dallas, Texas drew about 2,500 people, mostly protesters rallying against racism and calling for the removal of memorials to leaders of the pro-slavery Confederacy during the US Civil War.
Though there were some confrontations, there were no arrests or injuries, the Dallas Morning News reported.
And in Atlanta, about 2,000 people marched peacefully from downtown to the tomb of slain civil rights leader Martin Luther King Jr.