Nearly two days after a truck rammed through a crowded Christmas market in Berlin on Monday evening, killing 12 people and wounding dozens of others, police from around western Germany descended on the town of Emmerich, where the prime suspect in that attack, a 24-year-old Tunisian named Anis Amri, had been registered last year as an asylum seeker.

Dressed in full combat gear and carrying assault rifles and battering rams, the officers were ready by Wednesday afternoon to raid the shelter where they believed Amri to have stayed. But there was a problem. As a senior officer in the German police told TIME, the search warrant had not been properly filled out. Hours passed before the mistake was corrected. Journalists got wind of the operation in the meantime, setting up cameras around the shelter and alerting the public – as well as the shelter’s residents – of the impending raid.

It would take another half a day, until the early hours of Thursday morning, for police to finally storm the building. They did not find Amri hiding inside, nor anywhere else in Germany. Italian police shot him dead in Milan on Friday, marking the final humiliation in a series of fumbles that had tainted the investigation from the start. After the worst terrorist attack their country has seen in decades, the police could not even set up a dragnet tight enough to stop the fugitive from leaving the country.

“Of course some of the blame falls on the open borders of Europe,” says the senior German police official, who would only discuss the case on condition of anonymity Friday. “We did not impose total control at the border. We should have checked every train, every trailer. But that wasn’t done.”

Such regrets seem middling compared to the investigation’s other failures, which began soon after Amri arrived in Germany in July 2015, crossing the border along with the hundreds of thousands of other asylum-seekers who entered the country that summer from across North Africa and the Middle East.

For German police, Amri’s rap sheet would have made him an immediate security concern. Even before he set out for Europe as a teenager aboard a migrant boat in 2011, Amri was wanted in his native Tunisia for robbery and other crimes. Within a year of landing in Italy, he was arrested and sentenced to four years in prison for trying to set his migrant shelter on fire.

The time he spent behind bars in Italy would have put him at great risk of radicalization even before he entered Germany, says Ali Bas, a lawmaker in the German region of North-Rhine Westphalia who works on state programs to prevent the spread of Islamic radicalism among convicts. On this front, Germany has been ahead of the European curve; Muslim prisoners in many German cities are provided with Islamic education and pastoral services, which are designed to help them resist the influence of religious extremists inside the prison system. “The prisons in Italy don’t have that. They have not focused so much on radicalization,” he says. “So you have to think about the odyssey this Tunisian guy had in Europe before he came to us.”

But he would go on to find Islamists in Germany. According to German officials, Amri had come into contact with a number of ISIS recruiters and had also attempted to purchase a cache of weapons, expressing a desire to die in a suicide attack. Between March and September of this year, German intelligence services had him under intense surveillance, one among roughly 500 known extremists in Germany who pose the greatest risk of staging an attack. Even though the surveillance did yield evidence that Amri was a petty drug dealer in Berlin, it was not enough for the police to justify watching him around the clock after September.

The most they could do was try to deport him, but that also proved exceedingly difficult. Amri did not have a valid passport or other documents that Germany could use to establish where he came from. During one asylum interview, he claimed to be from Egypt, though he could not answer any of the interviewer’s questions about that country. The authorities in Tunisia then refused to repatriate Amri, a common problem for migrants from North Africa. So the German government was forced to issue him a temporary residence permit pending his deportation.

One of his preferred hangouts in Berlin while he waited for the Tunisian government to comply with the deportation order was a mosque that has long been associated with the ultra-conservative strain of Islam known as Salafism. He went to that mosque, in the central Berlin district of Moabit, just a few days before he hijacked the truck and drove it into the Christmas market on Monday evening. In perhaps the most astounding failing of the investigation that followed, Amri returned to that mosque hours after the attack, according to CCTV footage aired on Thursday by the German broadcaster RBB.

At the time, the German police were focusing on the suspect they had in custody – the wrong one. Apparently misled by a confused witness to the carnage at the Christmas market, officers arrested a Pakistani asylum-seeker about a mile away from the scene of crime on Monday night. “We have the driver,” Winfrid Wetzel, the chief spokesman for the Berlin police department, told me that evening, referring to the Pakistani. “There is no danger now to Berlin.”

But on Tuesday night, police were forced to release that suspect, as there was no physical evidence linking him to the crime scene. When they conducted a thorough search of the truck that day, they found a temporary asylum document made out in the name of Anis Amri. It was the first real breakthrough in the case, and it would have been reason enough, in many countries, to immediately plaster his face on the evening news.

Yet Amri’s name did not show up in the German media for roughly another day. Nor did his mugshot. Due to the stringent privacy protections enshrined in German law, the local press at first identified Amri only by his first name and last initial – “Anis A.” – and partially obscured his photograph for hours on Wednesday morning, waiting for federal police to issue an official wanted poster for the suspect later that day. Only on Thursday morning, when he could have been well on his way to Italy or already there, his picture appeared on the front pages of newspapers across Germany.

“It’s beyond belief,” says the senior police official, referring to such delays. “These things can’t happen. We should have moved fast.”

These sorts of recriminations – and far more sharply worded ones – have come pouring down on the German government this week, tarring everyone from the local police force in Berlin to Chancellor Angela Merkel. In a sign of the widening rift within the ruling coalition over how Germany has balanced security against the personal rights and freedoms of both its citizens and its refugees, Armin Laschet, Merkel’s deputy in the Christian Democratic Union, the party she has led for 16 years, said on Thursday that the failures in the investigation “can only leave one shocked about how the authorities have worked.”

In an interview with German radio on Thursday, Laschet also pointed to lack of coordination between the country’s regions, whose police forces often work autonomously of one another even when it comes to terrorism cases. When Amri went to Berlin from North-Rhine Westphalia early this year, for instance, the region’s investigators seem to have washed their hands of his case. “They said, ‘He’s gone to Berlin… So the case is settled for us. Now Berlin is responsible,” said Laschet.

That attitude was palpable among officials in Emmerich as well. Although Sabina Pullach, a member of the town’s Integration Council, which works with local migrants and refugees, conceded that Amri had “definitely” lived in the shelter that was raided on Thursday morning, “His ISIS connections were made in other regions,” she told TIME on Friday.

No one in the local community of asylum seekers could remember meeting him, and he had not taken advantage of the integration courses and other social programs that were available to him in Emmerich, she said. Instead he seems to have spent most of his time moving around the country. “They are totally free to travel,” Pullach said of the asylum seekers. “We can’t just come up and question them about what they’re up to, where they’re going. The refugees have their own freedoms. They have rights.”

Though hardly luxurious, the two-story brick shelter in Emmerich has all the basic comforts, with shared bathrooms and no more than four men sleeping on bunk beds in each room. In the leafy yard of the facility there is a trampoline and a ping-pong table, and locals have donated bicycles for the residents to use as well as videogame consoles and televisions.

With all these gifts to help them adapt to their new home, Hekmat al-Mashhdani, a 22-year-old asylum seeker from Baghdad, was shocked when German special forces barged into his room on the second floor at around five in the morning on Thursday, guns drawn. “They looked like terrorists,” he told me on Friday, pointing to the shelves and boxes the police had rummaged through in search of evidence.

After waiting all that time to gain access the officers were eager to find information on the suspect likely already hundreds of miles away. Showing al-Mashhdani a photo of Amri, the officers asked whether he recognized the man. No, he said; he had only arrived at the shelter this summer, when Amri had already moved to Berlin. And what else did they ask during the interrogation? “Nothing,” he told me in broken German. The police had not brought an Arabic translator to help them speak to the refugees.

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.