Britain faces a greater risk of terrorism as the Islamic State loses its grip on areas of the Middle East, said Ben Wallace, the country's security minister. His warning comes after 14 people were killed and dozens more injured when a van ploughed into people on Barcelona's Las Ramblas. It was a plot carried out by a terror cell thought to be loyal to the Islamic State.

Islamic State, also known as Isis, is all but defeated militarily in Syria and Iraq, where it once controlled swathes of territory after emerging from the chaos in the region in 2014 as a well-armed jihadist insurgency and declared the creation of a caliphate.

Now it is on the backfoot and rapidly losing ground. It has already lost control of Mosul, an important Iraqi oil city, and is almost run out of Raqqa in Syria, which was its de facto capital. A loose coalition including Kurds, moderate Syrian rebels, the Iraqi Army, and Western forces has for many months put Isis under pressure.

But military successes in the Middle East may have consequences at home in Europe, which Wallace said is now under "constant attack" by Islamist terrorists.

Wallace told BBC Radio 4's Today programme that the terror threat in the UK "is still increasing, partly driven by the fact Isis is collapsing in Syria and people are either unable to get out there to fight for Isis and so they look to do something at home, or also because people have come back and tried to inspire people with their stories and tales of the caliphate. I think those two things mean that the threat is to some extent increasing."

He backed the government's controversial counterterrorism programme Prevent, which seeks to identify and de-radicalise individuals vulnerable to extremist ideologies, including violent Islamism and those lured to the far-right.

"If we're going to stop these people who use everyday items such as vehicles and kitchen knives to murder people on our streets, we are going to have to all engage together with Prevent and we are having real success when we do that," Wallace said.

London Bridge terror attack
One of the attackers lies dead on the ground in Borough Market after police opened fire Gabriele Sciotto/Reuters

In the most recent terror attack on British soil, attackers mowed people down on London Bridge before leaving the vehicle and rampaging with knives through nearby Borough Market on 3 June. The three Isis-affiliated terrorists were shot dead at the scene, but not before killing eight people.

A few days earlier on 22 May, Salman Abedi killed 23 people, including children, at an Ariana Grande concert in Manchester when he detonated a suicide bomb packed with shrapnel. The 22-year-old had been in contact with Isis.

And on 22 March, jihadist Khalid Masood, 52, drove a car along the pavement of Westminster Bridge before crashing the vehicle and running towards the Houses of Parliament. He was shot dead after stabbing and killing a policeman. He had also murdered four people on the bridge. Though Isis claimed responsibility, Masood was not thought to be connected directly to the group.