A Turkish father and son running a kebab restaurant in Germany's Altena saved the town's mayor from certain death on Monday evening, during what appeared to be a xenophobic attack.

Andreas Hollstein was stabbed in the neck by the assailant identified as Werner S. while he was in the restaurant run by Abdullah and his son Ahmet Demir.

At a press conference yesterday, Hollstein thanked the father and son and said he "wouldn't be sitting here today if they were not there."

"I feared for my life," said the 57-year-old mayor who has received a German integration prize from Chancellor Angela Merkel. He said the attack took place in an atmosphere of growing social tension and hate. The attacker asked him if he was the mayor, before saying, "You let me die of thirst and let 200 refugees into Altena," Hollstein recalled. Then the man plunged a 30-centimeter-long kitchen knife into him.

Police told reporters that the suspect had been arrested and they believed his motives were xenophobic and political, although they took it to be a spontaneous attack, adding he had alcohol in his system.

Speaking to Hürriyet newspaper, 27-year-old Ahmet Demir said the mayor was a regular patron of the restaurant and were about to leave with takeaways when the assailant entered. "After asking him if he was the mayor, he tried to cut (Hollstein's) throat. I rushed to the mayor's assistance and grabbed the hand of the assailant. My father was at the back and ran to help me when he heard the noise. I tried to wrestle the knife from his hand and forced him to the ground. The mayor was very scared. My mother was at the restaurant too and she ran to a nearby police station. Before police arrived, the attacker was screaming "call in police, let them shoot me," he said. Demir said the man did not appear drunk and would have "certainly chopped the mayor's head off" if they did not stop him.

The attack comes as Germany struggles to deal with an increasingly fractured society. Many voters are still angry about the influx of more than 1.6 million people seeking asylum in the two years to the end of 2016.

In a September election, some 13 percent of Germans voted for the far-right Alternative for Germany (AfD) which campaigned hard against Merkel's open-door migrant policy.

"It brings us no further forward if we transmit political views with hate," Hollstein said. He said his wife had warned him about possible attacks due to his policies but he was determined to continue his work.

"I will push for refugees and for other people in a weaker social situation," he vowed, thanking the owner of the shop and his son for probably saving his life.

Under his leadership, the town of Altena, with 17,000 residents and 450 refugees, has taken in more migrants than it was allocated.

Politicians including Merkel expressed their shock.

"I am horrified by the knife attack on the mayor Andreas Hollstein - and very relieved that he can already be back with his family. Thanks also to those who helped him," Merkel said via her spokesman on Twitter.

The attack is reminiscent of the stabbing two years ago of a candidate for mayor of Cologne, Henriette Reker, in an anti-refugee attack. She was seriously hurt but went on to win the election and become mayor.