FREE now and never miss the top politics stories again. SUBSCRIBE Invalid email Sign up fornow and never miss the top politics stories again. We will use your email address only for sending you newsletters. Please see our Privacy Notice for details of your data protection rights.

The Spanish government tried to throw Abdelbaki Es Satty, 42, out of the country in 2014 after he served a sentence for drug smuggling. But a judge said two EU directives gave Es Satty the right to stay in the country - because he did not pose a “serious threat”. After the failed attempt to deport him, Es Satty went on to brainwash members of the cell who carried out two terror attacks in Barcelona and nearby Cambrils earlier this month.

GETTY Spain were prevented from deporting the suspected mastermind of the Barcelona attack by EU law

Today a 51-year-old German woman who had been in a critical condition in intensive care since being mowed down on Las Ramblas died in hospital. Her death brought the number murdered by the cell to 16. More than 100 more were injured when a van ploughed into pedestrians on the famous boulevard on August 17. A written judgment reveals judge Pablo de la Rubia blocked Es Satty’s deportation because of EU laws. The judge highlighted two EU Council Directives - numbers 2003/109/EC and 2001/40/EC - which prevented the Madrid government from booting him out. The EU directives say member states can only deport non-EU nationals who pose a "serious and present threat to public order or national security and safety".

This was not a failure. They asked us for information. We gave what we had Catalan interior minister Joaquim Forn

The judge ruled Es Satty was not a threat - because he had only been convicted of one offence and because he was making attempts to “integrate” into Spanish society. Es Satty was arrested in January 2010 on a ferry to Spain from north Africa, with 121 kilos of cannabis resin worth POUNDS 162,000 packed into a van. He was jailed for four years and a month and served two thirds of his sentence in a prison in Castellon, north east Spain. It is believed he became radicalised while behind bars.

When he was released in 2014 the Spanish government issued a deportation order, expelling him from the country for five years. Spanish law permits the government to deport foreign criminals who have been jailed for a year or more once they have served their sentence. Senior government official David Barelles wrote on the order that Es Satty posed “a real threat which is sufficiently serious to justify his expulsion”. But Es Satty appealed - insisting he had a right to stay in Spain despite his conviction.

Barcelona: The tragic victims of the Ramblas terror attack Sun, August 20, 2017 The cowardly terror attack in the Catalonian city of Barcelona has left 13 dead and 100 injured. These are the victims named so far Play slideshow PA 1 of 8 Julian Alessandro Cadman

His won his case at the Contentious-Administrative Court Number 2 in Castellon in April 2015. Citing the two EU directives, judge De la Rubia wrote: “Although the conduct of the accused is serious, there is only one offence, which is old, and it is claimed he has laid down employment roots in Spain, which demonstrate his efforts at integration into Spanish society.” The judge added that it would be “disproportionate” to deport the Moroccan. After leaving prison, Es Satty became the Iman of the mosque in Ripoll, a small town in the foothills of the Pyrenees, 65 miles north of Barcelona.

GETTY The Spanish government tried to kick Abdelbaki Es Satty out of the country in 2014

He radicalised local youths, mostly Moroccan immigrants aged 17 to 34, and is thought to have been the leader of the 12-man cell who brought mayhem to the region last month. The gang plotted a terrorist ‘spectacular’ using vans packed with bombs made from butane-gas bottles and the explosive TATP - nicknamed the Mother of Satan. They planned to blow up targets including the famous Sagrada Familia basilica. But the plot was foiled when their bomb factory in Alcazar, 125 miles south west of Barcelona, exploded - killing Es Satty and another member of the cell. Police initially thought the explosion was caused by a gas leak. They later found a book in the rubble linking the house, and specifically Es Satty, to ISIS. After the explosion foiled their original plan, the gang carried out a less sophisticated attack on August 17.

GETTY A German woman injured in the attack died today bringing the total number of victims to 16

Younes Abouyaaqoub, 22, drove a van down Las Ramblas, killing 14 pedestrians including seven-year-old Brit Julian Cadman, and injuring more than 100. Abouyaaqoub fled on foot and then carjacked Spaniard Pau Perez, 35, stabbing him to death and stealing his Ford Focus. Later that night five other members of the gang ploughed into pedestrians in the seaside town of Cambrils before going on the rampage with an axe and large knives, stabbing one person to death. Four were shot dead by a patrolling police officer, who happened to be a former elite soldier. The fifth was shot by another officer. Abouyaaqoub, the Barcelona van driver, was later cornered and shot dead by police last Monday.

GETTY A judge ruled that Es Satty was not a threat and so he was allowed to stay in Spain