The 22-year-old was influenced in part by the people who formed the Libyan Islamic Fighting Group, a little-known al-Qaida affiliate outlawed in 2004

“Whoever played with his mind, as he saw the kids coming out [of the arena] – all the happy faces – he should have changed his mind.” Those were the words late last week of Hisham Ben Ghalbon, a proud Manchester resident, a Libyan and a man, like so many others, wondering how what happened at the Manchester Arena ever came to pass.

Tragically, 22-year-old Salman Abedi didn’t change his mind. But what had formed and shaped its deadly rage? The search for an answer leads into the labyrinth of Libyan extremist politics of 20 years ago. A thread of resentment, violence and hardline theology that can be traced through Afghanistan and Gaddafi’s Libya, all the way to that country’s “second capital”, as Ghalbon puts it: Manchester.

Large part of Manchester attack network detained, police say Read more

There is little left of the Manchester premises of the Sanabel Relief Agency now. Shops and properties once rented by the charity, founded in 1999 with a mission to “relieve poverty, sickness and distress”, have long been vacated. Its board of trustees has been disbanded and its bank accounts closed down.

Indeed, if the agency exists anywhere at all these days, it’s in the files of the US treasury department which in 2006 sought to have Sanabel’s assets frozen on the grounds that it was a front set up to finance an al-Qaida affiliate.

That affiliate was the Libyan Islamic Fighting Group (LIFG), one of the more obscure terrorist organisations to have proclaimed allegiance to Osama bin Laden. Its influence and philosophy has been blamed for, at least partially, laying the foundations for Monday’s atrocity.

Formed in the early 1990s to fight the Soviet invasion of Afghanistan, the LIFG relocated to Libya where, in 1996, the US treasury department records that it attempted to assassinate Muammar Gaddafi “and replace his regime with a hardline Islamic state”.

When that plot – which some claim was backed by MI6 – failed, the LIFG was pursued by Gaddafi’s security forces. A large number fled to the UK, where they were granted asylum on the grounds that as opponents of Gaddafi “our enemy’s enemy is our friend”, and many went to Birmingham and Manchester – home to established Arab communities that had found work in the cities’ engineering industries.

“A lot who went to Manchester went to the Didsbury mosque – it was the only Arab mosque in that region and it was run by the Muslim Brotherhood,” said Haras Rafiq, chief executive of Quilliam, the anti-extremism thinktank.

Like the Brotherhood, the mosque preaches a Salafi fundamentalist form of Islam. While it has preached against the dangers of Islamic State and has fiercely condemned Monday’s attack, some of its members have been accused of raising funds for the LIFG , which was classified as a terrorist organisation in 2004, when the US sought to close down al-Qaida’s sprawling network of sympathisers following the 9/11 attacks.

Play Video 1:47 Manchester crowd joins in with woman singing Oasis after minute's silence - video

The LIFG’s main fundraising vehicle was the UK-based Sanabel charity which had offices and shops in Manchester, Middlesbrough, Birmingham and London. In addition to funnelling money around the globe to al-Qaida interests, it acted as an incubator for jihadis. Among those with important roles in Sanabel were Basheer al-Faqih, suspected of helping orchestrate the 2003 suicide bombings in Casablanca which killed more than 40 people. He was jailed in the UK in 2007 for possessing documents on how to make explosives and set up a terror cell.

Another crucial member was Abu Anas al-Libi, who ran the Afghanistan end of the Sanabel Relief Agency and had a £20m bounty on his head after his alleged involvement in the 1998 bombings of the US embassies in Tanzania and Kenya which killed 224 people. Libi was close to a third man, Abd al-Baset Azzouz, a father of four from Manchester. According to the US state department, Baset Azzouz “was sent to Libya in 2011 by al-Qaida leader Ayman al-Zawahiri to build a fighting force there, and mobilised approximately 200 fighters”.

The Libya fallout shows how Theresa May has failed on terror | Paul Mason Read more

All three men were close allies of another LIFG member who had fled Libya for Manchester and attended Didsbury mosque: Ramadan Abedi, Salman Abedi’s father.

Manchester’s 5,000-strong Libyan community has been left reeling by Abedi’s action, which Quilliam’s Rafiq suggests was the result of layers upon layers of indoctrination that contributed to his radicalisation. “How has he got to this point?” said Rafiq. “By osmosis. Through his father, through his connections, through the mosque, he has been absorbing Salafi ideology and theology.”

LIFG members reject the charge that they are extremists. But they do believe Libya should be run along strict Islamic lines. Ramadan Abedi was one of the many who took this view and returned – in a move that some say was tacitly endorsed by MI6 – to take part in the revolution that toppled Gaddafi. A Libyan who observed the return of the UK exiles was struck by the fact that they appeared unchanged by decades abroad.

“They espoused a very Islamist view of what their country should be,” the man said. “They were happy bearing arms, that they were in militias, that they were controlling the ministries. You have to ask the question: what did they gain from their UK experience? Did they learn anything from civil society like how should democracies work and the role of the citizen?”

In the UK, Gaddafi’s fall triggered celebrations among Manchester’s Libyan community. But the aftermath of the revolution brought chaos and then, in July 2014, a full-blown civil war after Libya Dawn, an Islamist Misrata-based militia coalition captured Tripoli, forcing the newly elected government to flee to the eastern town of Tobruk.

Facebook Twitter Pinterest A police cordon in the Moss Side area of Manchester where an army bomb disposal team was sent as arrests and raids were carried out. Photograph: Jonathan Brady/PA

Since then things have only got worse. Tobruk’s army commander, Khalifa Haftar, has captured the oil-rich Sirte basin and is continuing to fight Isis units and those of its Islamist rival, the Shura Council of Benghazi Revolutionaries, which is backed by Libya Dawn.

After his father returned to Libya, Abedi reportedly shuttled back and forth between a bustling Manchester and a traumatised Tripoli. Some reports suggest he was in Libya for the uprising in 2011 and was injured in 2014 in Ajdabiya in eastern Libya while fighting for an Islamist faction. But in neither country did he find a sense of belonging.

In Manchester he found it difficult to fit in and cut a contradictory figure. Friends describe a young man quick to anger, someone who was involved in drink and drugs and supported Manchester United, reacted violently to western sexual norms – once punching a woman for wearing a short skirt – and got into random fights.

He found some sort of identity in a violent gang subculture that saw alliances formed between different immigrant groups and which seemed to exalt death. Postings on social media sites remembering one deceased gang member who was a friend of Abedi’s show his photograph with the words: “If I die will the mandem [slang for gang] miss me, would they ride, talk about me when they tipsy, I can’t lie it feels like death wants to take me.”

In south Manchester, a man of Libyan origin who knows Abedi’s family, said the absence of his father must have had an impact. “Abu Ismail [a name used by Ramadan Abedi] has basically been in Libya since 2011, since when Salman was 16 or 17. This is a time when a boy really needs his father.

“Some of these young Libyan lads are pretty wild, especially those who fought in the revolution. There’s a problem with some getting into gangs. Some of them are off their heads, frankly. And by leaving Salman here to continue his studies, they couldn’t be sure what sort of company he was keeping. When he was young he was very quiet, respectful. But with what he’s done – he’s clearly off his head too.”

Play Video 0:47 Bikers join tribute rally for Manchester victim Olivia Campbell – video

Gareth Stansfield, professor of Middle East politics at Exeter University, said Abedi appeared typical of many second-generation migrants drawn to Islamist groups. “It’s the classic thing of being dispossessed, of having no roots. They see the perceived immorality of the west around them and these seeds are planted and become extremely toxic and poisonous.”

Alarmed by his son’s erratic behaviour, Ramadan Abedi apparently summoned him to Libya this year and confiscated his passport. Before he was arrested last week in connection with the investigation into his son’s actions, Abedi senior protested his son’s innocence and declared: “We don’t believe in killing innocents. This is not us.” Interestingly, Abedi senior’s Facebook page shows that he supported the Shura Council, a bitter enemy of Isis in Libya.

But it appears that at some stage Salman Abedi shrugged off his father’s allegiances and embraced Isis, something that may be an alarming portent, according to one terrorism expert.

“Traditionally an al-Qaida-associated group would have nothing to do or little in common with Isis,” said Stansfield. “In Syria they’ve fought pretty ferociously between themselves. They have some quite serious theological and ideological differences.

“But in recent years, boundaries have become more fluid, especially as situations in Libya and Syria have become far more complex and convoluted. Isis and al-Qaida are enemies and competitors but as pressure is brought to bear on both of them they have more in common than separates them.”

Manchester attack: UK terror threat level down from critical to severe Read more

Salman Abedi’s decision to embrace Isis may have been triggered by his experiences abroad. French intelligence suggests he was one of some 3,500 Libyans who went to Syria to fight. This has been played down by British intelligence but Abedi’s sister, Jomana, told the Wall Street Journal that he had been angered by what was happening in Syria.

“I think he saw children – Muslim children – dying everywhere, and wanted revenge. He saw the explosives America drops on children in Syria, and he wanted revenge. Whether he got that is between him and God.”

Unlike al-Qaida or the LIFG, organisations that take years to plan their actions, Isis offers an immediacy of response that appeals to a younger generation. “I use a virus analogy,” Stansfield said. “In disease terms al-Qaida is Spanish flu. It’s always there and can flare up in dangerous ways. You never fully eradicate it and it’s very durable. Isis is a bit like Ebola. It fires up all of a sudden, burns extremely brightly, but is too destructive and kills itself.”

That the sons of exiled LIFG members should want to take violent action in more urgent and terrifying ways is hardly surprising, Stansfield suggested. “They were teenagers when Gaddafi went. Life was difficult in Libya, and some viewed their country of exile with increasing animosity.

“Their influences are coming in from all over the place, from groups advocating ultra-radical, ultra-aggressive tendencies, presenting a massively complex, fractured and dangerous complex of dynamics, motivations and ultimately actions that quite frankly could overwhelm the capabilities of those agencies tasked with countering the threat posed by violent jihadi groups and individuals.”

One of those who police suspect may have influenced Abedi was Raphael Hostey, a recruiter for Isis who was brought up in Manchester’s Moss Side and is believed to have been killed in a drone strike in Syria last year. Hostey is credited with having persuaded hundreds of recruits to leave their own countries and fight for Isis. At least eight other young men and women from Moss Side have joined terrorist organisations and been jailed, gone missing or launched suicide attacks.

There are suggestions that Abedi may have been supported by accomplices in Germany, Canada and Turkey. Certainly few who knew him believe that he had the acumen to formulate the terrible plan he enacted on Monday.

But whatever the truth, the fateful journey that Abedi made to the Manchester Arena last Monday started long ago. “He’s not been radicalised by Isis,” Rafiq said. “His life story is all about being radicalised from birth and then Isis cherrypicked him.”