IT was the year that the “War On Terror” came back to bite British cities with the highest number of UK terror attacks since the height of the Irish troubles.

While the threat from the Middle East shows no sign of abating, security experts also fear the years ahead could see the return of Irish republican terror if border controls are reinstated after Brexit.

Dr Tim Wilson, director of the Handa Centre for the Study of Terrorism and Political Violence at the University of St Andrews, said: “The security services had been successful in preventing a major attack since 2005, which was a pretty good run of 11 years.

“Then several things happened in short order, starting with the Westminster Bridge and UK Parliament attacks in March, and then the events of May in Manchester with that horrific bomb attack where 22 concertgoers were killed.

“There was a Scottish dimension, with the poor girl from the Hebrides who got caught up in that which was devastating for such a small community.

“Then, just over a week later, the London Bridge attack with eight people and three attackers killed.

“That was pretty dramatic, and it’s pretty clear with the Parsons Green attempts in the middle of September to bomb a tube train, and indeed the recent raids in Chesterfield, there are still pots boiling away.

“It only takes one or two attacks to create a pretty spectacular gap in that record of prevention.”

It began on March 22, when Islamist extremist Khalid Masood ploughed a hire car through pedestrians on Westminster Bridge, near the Houses of Parliament, before launching a frenzied knife attack.

He stabbed PC Keith Palmer, 48, to death and also killed American tourist Kurt Cochran, Romanian tourist Andreea Cristea, 31, and Britons Aysha Frade, 44, and 75-year-old Leslie Rhodes, before being shot dead by police.

Then on May 22, 22 people - including children - were killed and dozens injured during a terrorist bombing at a pop concert in Manchester.

Suicide bomber Salman Abedi detonated an improvised explosive device as crowds of music fans, many of them youngsters, left the Manchester Arena following a performance by US artist Ariana Grande.

Eilidh MacLeod, 14, from Barra, was among the murdered victims while her friend Laura MacIntyre, 15, is still recovering from serious hand and leg injuries sustained in the attack.

On June 3, eight people were killed and 48 injured when three terrorists ploughed into pedestrians on London Bridge then went on a knife rampage in Borough Market.

On September 15, a bomb on the London Underground at Parsons Green injured 29 people, most of whom were said to have suffered "flash burns”. The improvised explosive device sent a fireball through the packed train carriage in London during rush-hour.

Wilson said: “To some degree, 2017 followed the script laid out since the Isis caliphate peaked.

“There has been a lot of chatter and predictions for well over a year that that entity would try and compensate for losing territory by staging attacks in western cities.

“That doesn’t necessarily mean they directly order these things in a linear, hierarchical way, but they inspire other people to do things.

“I did think that sort of prediction had been a long time coming, and we saw over the summer in the UK, and also in Barcelona, that prediction being fulfilled which was disturbing.”

Fourteen people were killed and 120 injured in the van attack in Barcelona's Las Ramblas boulevard on 17 August, and another man was stabbed to death in a carjacking as the van driver made his getaway. A woman died in an attack in nearby Cambrils the same day.

Wilson said: “There is an enormous mimetic effect to this. If one attack does go through then the potential for copycat imitations seems to rise as well, and sometimes in complex ways.”

He said the vehicle attack is “an example of a tactic that can be copied by very different actors with opposed ideological agendas”.

Darren Osborne, 48, has pleaded not guilty to murder and attempted murder, ahead of a trial in January in which he stands accused of deliberately driving a hired van into worshippers near the Muslim Welfare House in Finsbury Park, London.

One man, Makram Ali, was killed and 11 other people were injured on 19 June.

The mosque received death threats and racist hate mail in the wake of the incident, including one anonymous letter which said: "The attack using the van was only the beginning."

Wilson said: “One of the trends this year that it is worth commenting on is the tendency towards a kind of primitivisation of terrorist techniques.

“Manchester was an exception, as a major bomb, but the London Bridge model had not been seen before the Nice and Berlin Christmas Market lorry attacks in 2016, despite the fact that cars and knives have been around for a very long time.

“These things didn’t start this year by they certainly accelerated in 2017, and that is a phenomenon that we still don’t quite understand very well.

“It’s generally interpreted as a measure of the success of the security services, demonstrating that groups or individuals are finding it hard to build bombs so they’re turning to vehicle attacks instead.

“There is something to this, in that you can see that kind of trajectory in Barcelona where the cell involved seemed to have been building a bomb factory which blew up, so the vehicle attack in Las Ramblas was clearly a second best, even though they managed to kill 13 people.

“I would suggest this is, to some extent, encouraged by the communications revolution.

“Why didn’t we see attacks like this in the 1970s and 1980s, when it would have been easy to mow someone down in a truck?

“Well, we didn’t have streets full of camera phones. You can now stage an attack using primitive means and generate hundreds of films from the camera phones held by the people who were there.

“So, as the means of communication become more sophisticated the means of attack become more primitive.”

Scotland hasn’t seen a major terrorist incident since the botched Glasgow Airport bombing in 2007, but it remains on high alert following the incidents in Europe.

Security has been stepped up at major events, such as the Edinburgh Festival and forthcoming Hogmanay Celebrations, while Police Scotland relaxed deployment restrictions on armed police and announced a wider rollout of tasers.

Wilson said: “Lets not forget that at a UK level, the police are down by 20,000 officers so some moves (by Police Scotland) in the other direction, particularly in the specialist capability is probably not a bad idea.

“The Glasgow authorities will also be keeping a particularly close eye on developments in Ireland as well.

“It’s been a terrible year for politics in a region which could slide back into instability if things are mishandles with Brexit and the border.”

The snap general election in June saw the Conservatives reduced to a minority government, so it has been forced to turn to Ireland’s Democratic Unionist Party (DUP) for crucial votes.

There are widespread fears that the deal could disrupt the Irish peace process, and frustrate efforts to find an amicable solution to the border issues thrown up by Brexit.

Wilson said: “It’s hard to see how you can have an EU frontier without some form of monitoring arrangement, even with all the creative thinking going on.

“We know that the potential for instability tends to become enhanced in a political vacuum, and it looks like power sharing isn’t going to be restored anytime soon and we will instead be in for a period of direct rule.”

Northern Ireland has been without a government for almost a year, after the Stormont executive collapsed at the start of 2017 following a bitter row between the DUP and Sinn Féin over a failed energy scheme.

Wilson added: “We know from the troubles that what has tended to keep a lid on it is Dublin and London cooperating to make sure the differing communities and political agendas are listened to.

“I wouldn’t say we’re going back to the dark ages of mayhem that coincided with some particularly bad relations between Dublin and London, but there is undoubtedly renewed tension over Brexit.

“If any sort of customs infrastructure is reintroduced on the Irish border, you will have static sitting targets that will be attacked in some form of another by some form of dissident group. It will be a sitting target.

“One of the achievements of the peace process was getting rid of that, but that was predicated on both countries being members of the European Union.

“There is a long history, ever since the border was created in the 1920s, of such posts being attacked.”