Hundreds of thousands of demonstrators have marched through Berlin in protest against the far right, racism, and xenophobia.

Organisers said 242,000 people across Germany took part in the rally, making it one of the biggest in recent years.

It comes in protest against the rise in support for the far-right Alternative for Germany (AfD) party and ahead of a state election on Sunday.

Demonstrators carried banners reading: “Build bridges not walls”, “United against racism” and “We are indivisible - for an open and free society”.

The march was organised by human rights groups, labor unions, and a broad alliance of associations.

Voting will open for the Bavaria election on Sunday. German Chancellor Angela Merkel's southeastern allies, the Christian Social Union (CSU), are expected to win at most 35 percent, but lose their absolute majority, according to the latest polls.

Merkel’s 2015 decision to open Germany’s borders to more than 1 million migrants has boosted support for the AfD party. CSU leader Horst Seehofer has also caused the Chancellor problems by gradually shifting his party to the right in order to counter the rise of the anti-immigration Alternative for Germany (AfD) party.

While the number of violent attacks on refugees and asylum shelters in Germany has fallen sharply this year, Merkel has accused AfD politicians of using the violent protests to stir up social tensions.