Media playback is unsupported on your device Media caption IS is inspiring home-grown attackers rather than sending them to the front line, Ben Wallace says

The UK terror threat is increasing as so-called Islamic State loses territory in Syria and Iraq, the security minister has said.

Ben Wallace said extremists were trying to carry out attacks in the UK because they were either unable to join IS overseas or had returned from there.

He said Europe was now under "constant attack" from terror groups.

Mr Wallace also warned there needed to be more understanding of the anti-terrorism programme Prevent.

It comes after IS said it was behind the Barcelona attack on 17 August when a van drove down Las Ramblas, killing 13 and injuring scores more.

The terror group lost its Mosul stronghold to Iraqi forces last month and international efforts to bring down its "capital" Raqqa in Syria continue.

IS seized Raqqa in 2014 and established its headquarters there, with former prime minister David Cameron calling it "the head of the snake".

Mr Wallace told BBC Radio 4's Today programme: "I think the threat 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."

Image copyright Getty Images Image caption IS says it was behind the Barcelona attack on 17 August

The security minister also said it was vital for people to engage with the government's anti-terrorism programme, Prevent, which aims to stop people from becoming radicalised.

But he said he disagreed with comments from the police lead for Prevent who said the programme should be compulsory.

Under the scheme, police and other organisations try to build relationships with the public - including faith leaders, teachers and doctors - and urge them to report any concerns to them, but currently any engagement is voluntary.

Mr Wallace added that he had ordered the release of more information to increase understanding of Prevent and its successes to get more people to engage with it.

"There's no ifs and buts nowadays.

"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."

Mr Wallace added: "We must offer an alternative and help people be protected from that [radicalisation]."