BERLIN (AP) — Left-wing groups and Berlin residents prevented more than 500 far-right extremists from marching Saturday to the place where high-ranking Nazi official Rudolf Hess died 30 years ago.

Police in riot gear kept the neo-Nazis and an estimated 1,000 counter-protesters apart as the two sides staged competing rallies in the German capital's western district of Spandau.

Far-right protesters had planned to march to the site of the former Spandau prison, where Hess hanged himself in 1987, but were forced to turn back after about a kilometer (0.6 miles) because of a blockade by counter-protesters.

After changing their route, the neo-Nazis, who had come from all over Germany and neighboring European countries, returned to Spandau's main station for speeches amid jeers and chants of "Nazis go home!" and "You lost the war!" from counter-protesters.

Authorities had imposed restrictions on the march to ensure that it passed peacefully. Organizers were told they couldn't glorify Hess or the Nazi regime, carry weapons, drums or torches, and could bring only one flag for every 25 participants.

Such restrictions are common in Germany and rooted in the experience of the pre-war Weimar Republic, when opposing political groups would try to forcibly interrupt their rivals' rallies, resulting in frequent street violence.

Police in Germany say they generally try to balance protesters' rights to free speech and free assembly against the rights of counter-demonstrators and residents. The rules mean that shields, helmets and batons carried by far-right and Neo-Nazi protesters in Charlottesville wouldn't be allowed in Germany. Openly anti-Semitic chants would also prompt German police to intervene.

Neo-Nazi protesters on Saturday were frisked and funneled through tents where police checked them for weapons, forbidden flags and tattoos showing symbols banned in Germany, such as the Nazi swastika. A number of far-right protesters emerged from the tents with black tape covering their arms or legs.

Organizers imposed a number of their own rules on the marchers: they were encouraged to wear smart, white shirts and were told not to speak to the media.

Among those demonstrating against the neo-Nazis was Jossa Berntje from the western city of Koblenz. The 64-year-old cited the clashes in Charlottesville and her parents' experience of living under the Nazis as her reason for coming.

"The rats are coming out of the sewers," she said. "(President Donald) Trump has made it socially acceptable."

Hess, who received a life sentence at the Nuremberg trials for his role in planning World War II, died on Aug. 17, 1987. Allied authorities ruled his death a suicide, but Nazi sympathizers have long claimed he was killed and organize annual marches in his honor.

Those annual far-right marches used to take place in the Bavarian town of Wunsiedel, where Hess was buried until authorities removed his remains.