A Jewish student was badly injured on Sunday after a man attacked him with a shovel outside a synagogue in the northern German city of Hamburg, police said.

The 26-year-old man was struck repeatedly on the head as he was about to enter the synagogue in an attack denounced by Foreign Minister Heiko Maas as "repugnant anti-Semitism".

Police assigned to protect the synagogue arrested a 29-year-old man who was wearing a uniform resembling that of the Germany army.

According to Germany's DPA news agency, they found a piece of paper bearing a swastika in one of his trouser pockets.

The victim managed to get away from the attacker and passers-by gave him first aid before he was taken to hospital, the agency added.

A police spokesman cited by DPA said the suspect, a German of Kazakh origin, seemed to be in a confused state, which made questioning him difficult.

Ronald Lauder, leader of the World Jewish Congress, denounced the attack, pointing out it came a year after two people were shot dead after an extremist tried to storm a synagogue in the eastern city of Halle.

"Today's attacker must be held responsible as must all who engage in any expressions of hate or intolerance," he said.

Avichai Apel, president of the Germany conference of Orthodox rabbis, described the latest attack as a fresh shock for the Jewish community in Germany.

The Jewish community in Hamburg was celebrating Sukkot, also known as the Feast of the Tabernacles, and the synagogue was full of believers at the time of the time, according to media reports.

Last year's attack on the synagogue in Halle came on October 9 during Yom Kippur, the holiest day in the Jewish calendar. A neo-Nazi suspect is currently on trial for the crime.

Only last month, Chancellor Angela Merkel spoke of her shame over rising anti-Semitism in Germany, even as the Jewish community warned the coronavirus was acting as a catalyst stirring up anti-Jewish hatred.

Anti-Semitic crimes have increased steadily in Germany in recent years with 2,032 anti-Semitic offences recorded in 2019, up 13 percent on the previous year.

Some six million European Jews were murdered by Adolf Hitler's Nazi regime during World War II.

Germany is now home to the third-largest Jewish population in western Europe, largely due to an influx of around 200,000 Jews following the collapse of the Soviet Union.