Thousands of people have taken to the streets of Hamburg, Germany, to protest against a Group of 20 (G20) summit that takes place next weekend.

The G20 comprises leaders of the world's major industrialised and emerging economies. US President Donald Trump is expected to make his maiden appearance at the July 7 and 8 forum.

Sunday's demonstration in the northern German city was organised by environmental, labour, human rights and church groups protesting against the policies of the world's richest countries.

A police spokesman quoted by the AFP news agency put the turnout at the protest at around 10,000, while organisers said the figure was far higher.

OPINION: Are protests enough to bring down the G20?

The rally was "completely peaceful", the police spokesman said as more protests are expected in the run-up to the summit.

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.

More protests expected

Hamburg, where summit host Chancellor Angela Merkel was born, is a bustling city that is also an anti-establishment bastion of left-wing activists.

Around 30 protests have been scheduled in the run-up to the summit, and the organisers are hoping for a total turnout of more than 100,000 people.

German authorities are bracing for trouble in Hamburg as they are worried that the protests could turn violent.

The German Federal Crime Office warned that violent G20 opponents could carry out arson and sabotage at infrastructure targets such as the Hamburg harbour and airport, said on Sunday.

"New and creative forms of attack have to be watched out for," the German Federal Crime Office warned, according to the Welt am Sonntag newspaper.

Interior Minister Thomas de Maiziere, in the Sunday edition of the daily Bild, warned that any violence "should 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.

The G20 meeting follows a G7 summit in Sicily a month ago that exposed deep divisions between the United States and other countries on climate change, trade and migration.

Trump later announced he was pulling the US out of a landmark agreement to combat climate change reached in 2015 in Paris.