A police spokesman put turnout at the demonstration – the first of about 30 scheduled in the runup to the Friday-Saturday summit – at around 8,000, while the organizers claimed there were “more than 18,000 people”.
The protest was “completely peaceful,” the police spokesman told AFP.
The gathering outside city hall took place in parallel with protests by canoeists on the nearby river Alster, while in the port of Hamburg, Greenpeace staged a climate demonstration near a ship laden with coal.
The Group of 20 (G20) comprises leaders of the world's major industrialized and emerging economies.
At city hall, a number of speakers took the podium to call for “a different political approach”, urging respect for the environment or criticizing Trump.
“We need a fair distribution of wealth in Germany and across the world,” said Stefan Korzell of the German Trade Union Federation (DGB).
'Only interested in money'
The demonstrators then marched through the streets carrying a giant banner calling for “fair international commerce”, “climate rescue” and a “strengthening of democracy”.
“We are here to support the G20 summit protesters,” said 46-year-old Heike, who did not give his last name.
Michael, 50, said he was “against the G20 because the G20 is only interested in money.”
Around 30 protests have been scheduled ahead of the summit with organizers hoping for a total turnout of more than 100,000 people.
Hamburg, where Chancellor Angela Merkel was born, is an anti-establishment bastion popular with left-wing radicals, with officials saying they are bracing for possible clashes and property damage.
In Sunday's edition of Bild, Interior Minister Thomas de Maiziere warned that any violence would be “nipped in the bud”.
“Freedom of assembly is only valid for peaceful demonstrations,” he said.
Around 15,000 police will be deployed to protect the summit, in addition to 3,800 officers monitoring airport and train security.