HAMBURG (Reuters) - The migrant who killed one person and injured six others in a knife attack in a Hamburg supermarket was a radicalized Islamist known to German security agencies, but also believed to have psychological problems.

Police investigators work at the crime scene after a knife attack in a supermarket in Hamburg, Germany, July 28, 2017. REUTERS/Morris Mac Matzen

Officials said on Saturday the agencies had believed he posed no immediate threat.

A security lapse in a second deadly militant attack in less than a year, and two months before the general election, would be highly embarrassing for German intelligence, especially since security is a main theme in the Sept. 24 vote.

A Tunisian failed asylum seeker killed 12 people by driving a truck into a Christmas market in Berlin in December, slipping through the net after intelligence officers who had monitored him reached the conclusion he was no threat.

Hamburg Interior Minister Andy Grote told a news conference that Friday’s 26-year-old attacker was registered in intelligence systems as an Islamist but not a violent one as there was no evidence to link him to an imminent attack.

He also said the attacker, a Palestinian asylum seeker who could not be deported as he lacked identification documents, was psychologically unstable. Police said on Friday the man was born in United Arab Emirates.

The Palestinian mission in Berlin had agreed to issue him with documents and he had agreed to leave Germany once these were ready, a process that takes a few months.

Slideshow ( 7 images )

“What we can say of the motive of the attacker at the moment is that on the one side there are indications that he acted based on religious Islamist motives, and on the other hand there are indications of psychological instability,” Grote said.

“The attacker was known to security forces. There was information that he had been radicalized,” he said.

“As far as we know ... there were no grounds to assess him as an immediate danger. He was a suspected Islamist and was recorded as such in the appropriate systems, not as a jihadist but as an Islamist.”

Chancellor Angela Merkel, who is on a summer vacation and is seeking a fourth term in office in September, praised the civil courage of Hamburg residents who threw chairs and other objects at the attack, helping police to detain him.

“This violent crime must and will be investigated,” she said in a statement. “I thank the police for their effort and all those who stood up against the attacker with civil courage and bravery.”

Merkel’s decision in 2015 to open Germany’s doors to more than one million of mainly Muslim migrants has sparked a debate about the need to spend more on policing and security and contributed to the rise of the Alternative for Germany (AfD) populist party.

Yet her conservatives have recovered from losses in regional elections last year and are in a leading position to win the general election. Opinion polls put them 13-17 percentage points ahead of the centre-left Social Democrats.

The Hamburg attack did not feature on the front pages of most major broadsheets, which dedicated their coverage to the emissions scandal engulfing the German car industry.

Prosecutors said the attacker pulled a 20 cm (7.9 inch) knife from a shelf at the supermarket and stabbed three people inside and four outside. A 50-year-old man died of his injuries.

Prosecutors said the attacker, who had not been named, appeared on police records in April after he was caught stealing in a shop but he was convicted of no crime given the petty nature of his offense.