Ahmad Alhaw, 27, admitted to the murder and assaults in the river port city of Hamburg in January and was sentenced today

A Palestinian asylum seeker who stabbed a man to death and injured six others during a rampaging attack at a German supermarket was sentenced to life in prison.

Ahmad Alhaw, 27, admitted to the murder and assaults in the river port city of Hamburg in January and was sentenced today.

Grabbing an eight-inch knife from the shelves on July 28 last year, he shouted 'Allahu Akbar' as he set upon a 50-year-old woman and four men.

The judge said the 'particular severity' of the crimes lowered Alhaw's chances of being able to apply for early release on parole.

The attack stemmed from a 'radical Islamist' motive and Alhaw hoped to 'die as a martyr', prosecutors said. They added he wanted to kill as many German Christians as possible to avenge the suffering of Muslims worldwide.

'He wanted his actions to be viewed in the context of an Islamist attack, and understood as a contribution to jihad worldwide,' they added.

A 20-year-old store assistant who witnessed the attack said: 'I saw him run toward me, covered in blood. He was radiating bloodlust.'

After Alhaw emerged from the supermarket, seven mostly migrant bystanders tried to stop the screaming attacker, throwing rocks and chairs at him to slow him down until police arrived.

The men - among them a 30-year-old man of Turkish descent who was wounded in the struggle - have since been celebrated and honoured for their courage.

Scroll down for video

But he surprised the court in a February 19 hearing when he appeared with his beard shaved off and for the first time showed remorse. Alhaw awaiting a verdict in court in Hamburg today (pictured)

One of them, Afghan asylum seeker Toufiq Arab, told Bild daily: 'I'm not a hero, I only did my duty.'

Alhaw's attack was the first in Germany since December 2016, when Tunisian Anis Amri rammed a stolen truck into a Berlin Christmas market, killing 12.

Like Amri, Alhaw was due to be deported after his asylum application was rejected, although this process was slowed down as they had to wait for identity documents.

Through an Arabic translator, Alhaw told the court he had sought asylum in Norway in 2009 after giving up dentistry studies in Egypt, hoping for a better life in Europe.

After his application was rejected, he moved around the EU, living in Sweden, Spain and finally Germany.

He was 'fascinated' by the Western lifestyle and enjoyed drinking alcohol and smoking marijuana, with only 'phases' of religiosity, Alhaw said.

But 'he had the feeling that he was not welcome in these countries,' he added.

Alhaw himself declined to discuss his suspected religious radicalisation or details of his crimes.

'He knows that he has committed very serious crimes and knows he will be sentenced for them,' defender Burchard said.

Alhaw had watched ISIS propaganda videos online, grew increasingly religious and became distrustful of state authorities

'He wanted his actions to be viewed in the context of an Islamist attack, and understood as a contribution to jihad worldwide,' they added. Pictured: Ahmad Alhaw in court in January

Prosecutors told the court in Hamburg that it was 'important' to Alhaw, 26, to 'kill as many German nationals of the Christian faith as possible'

Security services had come under scrutiny after failing to recognise Alhaw was self-radicalising in the lead up to the attack. He had watched ISIS propaganda videos online, grew increasingly religious and became distrustful of state authorities.

By 2016 he thought that he suddenly understood the Koran completely, rejected all previous temptations, and started looking at all other people as either true believers or non-believers, the psychiatrist said.

Alhaw said the knife attack had not been his decision but God's will.

But he surprised the court in a February 19 hearing when he appeared with his beard shaved off and for the first time showed remorse.

Alhaw took an eight-inch knife from the shelves of a supermarket last July before using it to kill one and wound six in the assault. Pictured: The scene outside the supermarket after the attack

Alhaw was due to be deported after his asylum application was rejected, but the process had been delayed due to a lack of documents. Pictured: The scene of the attack in July

'Unfortunately I can't turn back time,' he told the victims and the relatives of the man he killed. 'All I can do is to ask you for forgiveness.'

Alhaw had told interrogators that the crime 'had some connection with events on the Temple Mount' in Jerusalem, where Israeli authorities had recently imposed anti-terror controls for Muslim worshippers, prosecutor Yasemin Tuz told the court.

'The results of the investigation show that the accused sought out his victims indiscriminately, retaliating against people who in his view represent perpetrators of injustice targeting Muslims,' prosecutors had earlier said.

Investigators, however, did not find any evidence to suggest that Alhaw was a member of ISIS.

Through an Arabic translator, Alhaw told the court he had sought asylum in Norway in 2009 after giving up dentistry studies in Egypt, hoping for a better life in Europe. Pictured: The scene of the attack in July