Police officers secure the area July 28 after a knife attack at a supermarket in Hamburg. A suspect police have only identified as Ahmad A. allegedly stabbed six people, one fatally. A seventh person was wounded in an attempt to overcome the suspect. (Markus Scholz/DPA/AP)

For months, Germany awaited paperwork from the Palestinian Authority to carry out his deportation, but it took only a moment, police allege, for the man they have identified only as Ahmad A. to wield a knife in a rampage in a Hamburg supermarket. 

He stabbed six people, one ­fatally. A seventh person was wounded in an attempt to overcome the suspect, who will face charges for murder and attempted murder, as well for causing grievous bodily harm. 

The 26-year-old Palestinian, born in the United Arab Emirates, wanted to die a martyr, prosecutors said. His attack last month has renewed questions about whether Germany has control of its borders, prompting recriminations from opposing political factions ahead of a September election that will be a referendum on the nation’s chancellor, Angela Merkel

In its response to the refu­gee crisis, Germany has aimed to prove that humanitarianism and national security are compatible. But the debate over deportations captures how these principles come into conflict, legal experts and practitioners said, and is therefore exemplary of Europe’s broader movement toward a  stricter policy.  

As Germany stiffens its stance on immigration, in a manner at odds with the open-door policy for which it is known, deportation has emerged as a critical measure of state security. The case of ­Ahmad A. appeared to reveal gaps in that architecture, a point reflected in the outcry of politicians and the media.

“The deportation talk is a way of Germany saying, ‘We have control; we are in the driver’s seat,’ ” said Carsten Hörich, an expert in migration law based in the city of Halle. 

But experts said new legislation is unlikely to remove practical barriers to deportation, such as the fact that many migrants arrive without passports. Other barriers, they said, involve human rights concerns — from health problems to the status of minors.

Germany deported more than 25,000 people in 2016, an increase of about 5,000 from 2015. In the first half of this year, 12,500 people have been deported, according to the Interior Ministry. 

The suspect in the Hamburg case was meant to be one of them. But the federal migration office missed a deadline in 2015 to send the man back to Norway, the nation responsible for his asylum claim under European rules. His request for asylum in Germany was then dismissed toward the end of last year, again putting him on the path to deportation. But he didn’t have a passport dictating where he had to go. Police said he was cooperating as authorities tracked down identification documents from the Palestinian Authority, which can take months. 

Around the same time, however, a friend of the man had warned security officials of his possible radicalization, and then, in the spring, a shoplifting case that was later dismissed put him on the police’s radar. Still, he wasn’t considered an imminent risk, classified as an Islamist instead of a jihadist, said Andy Grote, the interior minister of Hamburg. Authorities also said he suffered psychological distress.

But the man, who was living in a refugee home in Hamburg, quickly self-radicalized, federal prosecutors said. Only two days before the attack, he chose to adopt a lifestyle matching his “radical Islamist” beliefs, they said.

The case has drawn parallels to one of the most deadly strikes in decades, when a young Tunisian ex-convict and failed asylum seeker drove a truck into a Christmas market in Berlin in December. The Islamic State asserted responsibility, whereas the suspect in Hamburg operated without instructions from a broader network, authorities said. 

Still, across the political spectrum there were calls for a crackdown — from detaining radicalized individuals to thwart attacks, to putting economic pressure on nations to force them to readmit migrants. This chorus meant that Alternative for Germany, the far-right party poised to enter the German Parliament for the first time, was not alone in demanding that the country rethink its immigration policy. 

The message was echoed in the German media. Bild, the country’s top-selling tabloid, wrote of “the great deportation lie,” noting that the number of deportations in 2017 was lower than at this time last year.

“We see this every time something shocking happens,” said Heiko Habbe, an attorney with Fluchtpunkt, a Hamburg-based legal aid group. “You can draw a line over the last 15 years with ever-stricter laws, but if we want to live in an open society, we cannot prevent every danger.” 

A day after the attack, a new measure went into effect making it easier to detain and deport migrants. It authorizes new forms of electronic monitoring and strips away the need to give prior notice of deportation in certain cases. But Habbe said it would not have applied to the Hamburg suspect because he was not flagged as a danger, or “Gefährder.”

This classification has existed in German law as grounds for preventive deportation of foreigners, meaning those without an expulsion order, since 2004. It requires that the security of the nation be at stake. But the classification has not been used until this year, said Anna Katharina Mangold, a law professor at the ­University of Frankfurt. Since then, several courts have turned back challenges on constitutional grounds.

“Fundamental rights of foreigners do not seem too important in times such as these,” Mangold said.

On Monday, however, the European Court of Human Rights stopped a deportation justified on these grounds — of an 18-year-old from Dagestan living in Bremen in northwestern Germany — that had been planned for Tuesday. Both Germany’s Federal Administrative Court and Federal Constitutional Court had upheld the deportation. The European Court of Human Rights will review the case.