Police, who were out in force to keep the groups apart, said the march organised by the anti-immigrant, anti-Islam Alternative for Germany (AfD) drew over 5,000 supporters while the counter-demonstrators numbered more than 25,000.
The rallies passed off largely peacefully, although Berlin police said on Twitter that they had to use pepper spray to stop “demonstrators from trying to break down barriers” at one square.
Elsewhere, two dumpsters were set alight with fireworks and rolled onto the street, injuring a female demonstrator, they wrote.
AfD supporters kicked off their march “for the future of Germany” shortly after midday at Berlin's main train station, before walking to the iconic Brandenburg Gate, with many waving Germany's black, red and gold flag.
Along the route, their chants of “Merkel must go” and “We are the people” were occasionally drowned out by whistles, jeers and outstretched middle fingers from counter-demonstrators in side streets blocked off by police.
'Merkel is not Germany'
The AfD march marked the first public show of strength by the nationalist outfit since it became the largest opposition party, surfing a wave of anger over Chancellor Angela Merkel's decision to allow in large numbers of mainly Muslim refugees at the height of Europe's migrant crisis.
“Now we know that many Islamists were among the refugees and they have no respect for women,” 41-year-old AfD member and teacher Christine Moessl told AFP.
Addressing the crowd, AfD chairman Alexander Gauland said “Merkel is not Germany”.
“We love our country. And we want to pass it on to our children the way our grandfathers did for us.”
AfD deputy leader Beatrix von Storch, the granddaughter of Adolf Hitler's finance minister, told demonstrators that Germany was “a prime example of failed integration”.
Organisers of the far-right rally had initially predicted a turnout of 10,000, before saying they would be happy with some 5,000 people.
Berlin AfD chief Georg Pazderski said that many still feared being “stigmatised” for showing their AfD colours, even after the party took nearly 13 percent of the vote and won its first seats in the national parliament in last year's elections.
'Bass away the AfD'
Meanwhile, thousands of others joined a slate of anti-AfD demos, taking to the streets and the water to make themselves heard.
The main demo was staged by the “Stop the hatred, stop the AfD” alliance, which included political parties, unions, student bodies, migrant advocates and civil society organisations.
Walking in the strong Berlin heat, supporters waved rainbow flags, blew bubbles and carried signs that said “Racism is not the alternative”, while chanting “Go away, Nazis” and “the whole of Berlin hates the AfD”.
“The AfD is not trying to solve problems, but to divide society,” said 48-year-old Knut Haemmerling.
“It's scary to think what will happen if the party gets bigger,” added 76-year-old, Syrian-born Yesra Zubaidi.
One of the loudest counter-demos was organised by some 100 clubs from Berlin's legendary techno scene, who used boats and floats on the river Spree and a convoy of DJ-carrying trucks to “bass away” the AfD.
“The Berlin club culture is everything that Nazis are not,” they said in a statement.
“We are progressive, queer, feminist, anti-racist, inclusive, colourful and we have unicorns.”
Berlin police had deployed 2,000 officers, drafted in from across Germany, to keep the peace.
Ahead of the demos, members of the far-left extremist Antifa movement had on their website called for “chaos”, urging sympathisers “to sabotage the AfD rally using all necessary means”.
Founded in 2013 as an anti-euro party, the AfD rose to prominence by capitalising on widespread anger over the arrival of over a million asylum seekers in Germany since 2015.
It now holds more than 90 seats in the Bundestag where its presence has changed the tone of debate.
Just this month, AfD co-leader Alice Weidel earned herself a formal rebuke from the parliamentary speaker for describing immigrants as “headscarf girls, welfare-claiming, knife-wielding men and other good-for-nothings”.
Merkel's left-right coalition government has responded to the AfD's rise by tightening asylum policies, but the party continues to climb in opinion polls.