As the nightmare first seconds of Michael Adebolajo and Michael Adebowale's attack on Lee Rigby unfolded, there was a sign before them of how far they had strayed from their adopted religion.

They believed murdering a British soldier would please Allah and be a strike against the foreign policy of the west. They drove a car into Rigby, catapulting him on to the bonnet.

To the zealots, Rigby was an enemy they were about to behead. To Saraj Miah, a Muslim man who happened to be nearby and was wearing a white prayer cap as a sign of his devoutness, he was a human being in desperate trouble.

Miah had been smoking a cigarette outside a shop in Woolwich, south London, when he saw Adebolajo get out of his car with a cleaver in his hand and slash at the neck of a man on the ground, as Adebowale stabbed at the body. Miah was the first person to try to save Rigby, shouting "don't kill him" at the attackers. To ward Miah off, one aimed a gun at him, forcing him to back away.

How Adebolajo and Adebowale became radicalised to the point that they wanted to butcher a man in broad daylight did not form part of the court case. But it is the crucial issue facing the government, the counter-terrorism establishment and communities across Britain, an issue they have been grappling with since the modern age of terrorism began in the mass bloodshed of the September 11 attacks on the US in 2001.

Adebolajo and Adebowale are the first terrorists in Britain inspired by al-Qaida to plot murder, kill their victim and survive to answer questions. From a search for what drove them emerges a complex mix of a battle to control Islamic teaching, extremists in Britain and Africa, the internet, the attackers' personalities and how they interpret the modern world around them.

The story of Rigby's murderers shows that the ideology of violent jihad retains the power to capture young Britons and render them capable of savage acts of which they are proud.

After the murder Adebolajo and Adebowale did not attempt to flee but remained at the scene and tried to turn modern technology – smartphones with cameras – into a tool of propaganda. They posed for pictures before Adebolajo talked into cameras and justified the slaughter, his hands covered in blood from his victim.

Then Adebolajo, 29, and Adebowale, 22, rushed armed officers as they arrived, brandishing their knives and cleaver and an unloaded gun. They claimed they wanted the officers to shoot them dead and thus make them martyrs. They were shot and wounded, detained and taken to hospital. During police interviews and then before the jury that convicted him, Adebolajo said he had picked his target at random, viewed himself as a soldier and calculated the degree of suffering to inflict on his victim.

On his first day of police interviews, Adebolajo explained how he and Adebowale had driven to the barracks in Woolwich in a Vauxhall Tigra on 22 May. The day before he had bought knives from an Argos store and a knife sharpener. Adebolajo told detectives they were determined to stun and then murder a soldier – any soldier – because he was "the most fair target because he joins the army with kind of an understanding that your life is at risk".

He added that they attacked Rigby – who was returning to the Woolwich barracks from a recruitment fair, dressed in a Help for Heroes sweatshirt – because "it just so happened that he was the soldier that was spotted first".

At times during the interviews Adebolajo wrapped himself in a light blue blanket taken from his cell, because he felt cold. Speaking in a matter-of-fact way, he said: "It was almost as if Allah had chosen him … when I thought about obeying Allah in the past I thought maybe it is possible to kill a man by driving into him.

"When he crossed the road in front of me … it was almost as if I was not in control of myself.

Michael Adebolajo wrapped in a blue blanket during a police interview after the killing. Photograph: Reuters

"I accelerated. I hit him and I think I crashed into a signpost. We wished to fulfil our promise to Allah. We did not wish to give him much pain.

"I could see he was still alive … we exited the vehicle and I am not sure how I struck the first blow … the most humane way to kill any creature is to cut the jugular … he may be my enemy but he is a man … so I struck at the neck and attempted to remove the head."

Adebolajo has been assessed as being sane before his interviews, with no history of mental problems. The video images of Adebolajo at the scene at first seemed to show someone out of control. But the truth may be even worse: that his thinking was warped into believing his adopted religion allowed him to decide all the world was a battlefield and that he was entitled to kill a soldier.

Other terrorists who have attacked in Britain wanted to kill as many civilians as possible; Adebolajo and Adebowale had decided to target one soldier.

Rigby, 25, who was from Middleton, Greater Manchester, was the father of a two-year-old boy, Jack. He had served in Afghanistan and was described by senior officers as a "professional and incredibly brave" soldier who had faced gun battles with insurgents and patrols at risk of improvised explosive devices.

Off duty and returning to barracks after the recruitment fair at Tower Bridge, he can have had no idea of the horror that awaited him as he turned on to Wellington Street. In the dreadful moments after the attack one woman at the scene asked Adebolajo if he was going to harm the passersby. Adebolajo said: "No, the women and children are safe. You need to keep back when the police and the soldiers get here."

He gave the warning because he and Adebowale planned to rush at armed police, who were then arriving, while brandishing a gun and knives, hoping to be shot dead.

The British academic Paul Gill, who has studied terrorists for a US government study, said they may have chosen to be discriminate in their target because they believed it would make it "more difficult to paint their actions as the work of 'madmen' or 'lunatic extremists'".

Adebolajo thought of himself as a soldier. Despite his arrest, after his video confession, after being shot, and despite his detention, he thought he could still be in control. He ignored legal advice to say nothing and refused to talk to detectives if he did not like their attitude.

While Adebolajo was in hospital he had a standoff with police. He wanted to wash his hands, which were covered with the blood of his victim, but officers wanted to take forensic samples to help establish his guilt. Adebolajo told police: "I'm not going to deny anything."

Lee Rigby was returning from a recruitment event when he was killed. Photograph: MoD/PA

The young Muslim convert

Adebolajo was the dominant of the two attackers. He was born on 2 December 1984 to a Nigerian Christian family. His mother was a social worker, his father a psychiatric nurse manager in the NHS. The upbringing was strict, and his parents placed great emphasis on education.

Discipline did not stop the young Adebolajo going off the rails. His mother moved her family out of Romford, Essex, to Lincolnshire in an attempt to remove him from the influence of a street gang after he started getting into trouble. But her son returned to the capital to go to Greenwich University, where poor performance led to him dropping out of the course by his third year.

He had become interested in Islam and converted in his first year at university. The extremist cleric Omar Bakri Mohammad said he tutored Adebolajo in Islam after his conversion in 2003. Bakri Mohammad was the former leader of al-Muhajiroun, an organisation banned for professing extremist views. Several al-Muhajiroun followers have gone on to be convicted of terrorist offences in Britain.

Mohammad described Adebolajo as a shy man who had been angered by the Iraq invasion, and who would ask questions about when violence was justified. "He asked these types of questions, like many others," said Bakri Mohammed. "He was asking what to do. He was most likely affected by the situation in Iraq and Afghanistan."

Bakri Mohammed, now banned from Britain, said that as a new convert, Adebolajo received special attention: "In 2004 Muslims were feeling a lot of pressures from new laws and from Iraq."

He appears to have later attended events organised by successor groups to al-Muhajiroun until around 2011. By 2012 he claimed to have left the group.

Adebolajo fathered six children, the last born four days before Rigby's murder. He was well-read and described as pleasant by some who knew him, but with a temper. There were signs of an emerging mindset of a man attracted to the militant end of Islam from his association with Bakri Mohammed.

Adebolajo adopted a Muslim name, Mujaahid, which means one who engages in jihad. In court he renamed himself in honour of Abu Hamza, the extremist cleric extradited to the US last year, and asked to be known as Mujaahid Abu Hamza.

Gill said: "Not one of these behaviours could predict his eventual violent attack but together they tell a story of an individual becoming more deeply entrenched in militant activism."

Kenya

Adebolajo's friends say that in around 2010 he was receiving approaches from the domestic security service, MI5, asking him for information about his fellow extremists. That year Adebolajo travelled to Kenya. Some friends and family say the reason was to start a new life and to escape MI5 harassment. Others believe he was following a path trodden numerous times by jihadi wannabes. Kenya is the gateway to the lawless spaces of Somalia and the terrorist group al-Shabaab. The available evidence points to increasing radicalism being his reason for the journey.

For the west, the fight against extremism in east Africa is taken so seriously that Britain funded the construction and equipment for a Kenyan police centre as a base for anti-terrorism operations. The country receives money from the US to combat violent extremism.

Soon after arriving in Kenya Adebolajo ended up alongside people and in places associated with some of the leading al-Qaida-inspired terrorists in the region. He entered Kenya on 21 October 2010 on a scheduled flight to Nairobi. A man fitting his description was seen visiting a Mombasa mosque, Masjid Mussa, frequented by Samantha Lewthwaite, the so-called white widow, a wanted in Kenya for alleged links to terror offences. The green and white mosque on Mwambundu Road is one of the focuses for radical Islam in the city.

The main attraction at Friday prayers in 2010 was Sheikh Aboud Rogo Mohammed, a radical preacher who had amassed a significant following with outspoken sermons in support of al-Qaida and its Horn of Africa affiliate al-Shabaab. He was the ideological leader of al-Hijra, a Kenyan affiliate of al-Shabaab, named in intelligence reports as being responsible, along with al-Shabaab, for the Westgate shopping mall attack in September this year that killed at least 67 people.

Aboud Rogo's Friday sermons featured regular calls for Muslims from Kenya and elsewhere to travel to Somalia and join al-Shabaab in their jihad against foreign forces. Today, Aboud Rogo is Mombasa's most famous Islamist martyr. In August 2012 he was killed in a drive-by shooting.

The Mussa mosque is likely to be where Adebolajo met Swaleh Abdul Majid, a young man who would in 2011 marry the daughter of Aboud Rogo.

On 20 November 2010 Adebolajo caught a bus north out of Mombasa towards Lamu, a chain of tropical islands fringed with mangrove forests near the border with Somalia. The archipelago's remoteness has made it a staging post in reaching Somalia for al-Shabaab's recruitment network. Aboard the bus were five others, including the future son-in-law of Aboud Rogo, and four boys in their late teens. The group hired a speedboat to take them an hour's ride north to Pate Island and the remote village of Faza. Pate island was the home of al-Qaida's then leader in east Africa, Fazul Abdullah Mohammed.

Adebolajo and his companions arrived at 8pm and stayed at the basic Faza guesthouse. At first light the party moved on to Kizingitini, a nearby island that locals said was the launching point for the crossing to Somalia.

It was there that they were arrested by Kenya's controversial anti-terror police unit (ATPU), with the apparent assistance of a foreign intelligence service. The arresting officer, Inspector Stephen Khamisi, later told the magistrate that the ATPU had received outside intelligence reports leading them to intercept the group. Nine men were arrested and transferred to Mombasa. At the arraignment hearing held on 23 November 2010 they were accused of being on their way to Somalia and remanded in custody to allow police time for further investigation.

Court papers obtained by the Guardian show that by a second hearing four days later, names of four of the nine people remanded in custody had disappeared from the court record, including that of Adebolajo.

The conduct of the original hearing, as well as statements made in the dock and subsequent testimony, have given rise to two competing theories concerning Adebolajo, his travel companions and the role of the British high commission in obtaining his release. The first theory is that Adebolajo was planted on the bus to infiltrate a group of would-be militants, and that he was not meant to be detained. Certainly, the Kenyan government believed his arrest and return to the UK was not meant to be public.

Michael Adebolajo with bloody hands at the scene in Woolwich. Photograph: ITV

The second theory is that the Briton was a budding jihadist whose radicalism was further inflamed by mistreatment during his three days in custody. Aboubakar, a local lawyer retained by a Mombasa sheikh on behalf of the parents of three of the younger boys in the arrested group, said there had been serious concerns that they could be tortured by the ATPU.

He said the boys told him there was "more than one white man present at the arrests". At his court appearance the Briton was caught on video saying: "These people are mistreating us and we are innocent, believe me."

Both theories of Adebolajo's intent in Lamu and his treatment in Kenyan custody rely on the contradictory testimony of his fellow detainee Swaleh. Now in hiding as he claims to be at risk of assassination, he has variously told relatives that he did not know Adebolajo before boarding the bus with him for Lamu and that he was "suspicious" of the foreigner; and that the pair became acquainted on the bus and quickly decided to travel together.

Another radical cleric, Abubakar Shariff, who has taken up the mantle of the murdered Aboud Rogo and Ibrahim Omar, says Swaleh told him privately that Adebolajo had been threatened with sexual assault while in the custody of the ATPU. He said the Briton had been stripped and threatened with rape with the muzzle of an AK-47. But Kenya's coastal province police chief, Aggrey Adoli, denied all allegations of mistreatment or torture, saying: "The police do not abuse suspects."

A spokesman for the ATPU, Boniface Mwaniki, said the Briton was "deported" on 26 November. However, Kenyan immigration officials have privately contradicted this account, claiming he left on a commercial flight and his passport was not stamped with an order forbidding any re-entry to the country – standard practice in the event of deportation.

Returning home

On his return to the UK, Adebolajo claimed to friends and family that his harassment by MI5 continued as intelligence officers pressed him to be an informer. According to family members he told of being beaten and threatened with sexual violence and death. His family say he returned to the UK a changed and embittered man.

In 2012 Adebolajo and his family went to a group called CagePrisoners to complain about his treatment. His brother, Jeremiah, who was working at a university in Saudi Arabia, claimed he had been approached and pressured by MI6 for information.

Adebolajo said there was British complicity in his ill-treatment in Kenya. He confided in a friend, talking of abuse at the hands of the Kenyans. He also claimed that on 12-13 March 2012 an MI5 agent had met him in central London. According to a CagePrisoners note, Adebolajo said the agent pressed him to work for MI5, and sent several text messages to keep up the pressure. The last one read: "We have no option but to proceed without you."

MI5 is also alleged to have pressured other family members to use their influence to get Adebolajo to co-operate with the security service.

A friend who cannot be named for legal reasons said Adebolajo became radicalised in late 2012. The friend saw profound changes in his character, which he attributed to his experiences in Kenya and on his return to Britain. Adebolajo had described to his friend how during interrogation "they told him: 'You are not in the UK now.' They took his private parts and said we will F-you [sic]. He told me he was physically assaulted and sexually threatened. If you looked at his face, he was holding back tears," the friend said.

When Adebolajo returned to England he was interviewed by MI5 officers. The friend said: "His whole concept was he wanted to live in a Muslim land because at the time he was being harassed by MI5. They were knocking and knocking on his door. He pretended not to be there but then he spoke to the agent. They said we just want to speak to you and they wanted to ask him if he knew certain people." The friend said he believed Adebolajo declined MI5's offer. "His word was: 'They are bugging me,'" he said.

Less than a year before the attack, Asim Qureshi from CagePrisoners saw Adebolajo, and his sister Blessing. Their main concern was alleged threats from the security services to their brother Jeremiah. Qureshi said he was struck by how in control of himself Adebolajo was and also by how lucid he was.

Adebolajo said he had been in al-Muhajiroun, but had left feeling a spiritual element was missing.

There is one report placing Adebolajo as a regular volunteer at an extremist stall outside a bank in Woolwich High Street handing out Islamist propaganda in the runup to the murder. One witness said he had been seen outside Plumstead community centre encouraging people to fight in Syria.

But the week before the attack should have been one of joy for Adebolajo. His wife gave birth to a son, his sixth child. Instead, he and Adebowale were planning the attack on a soldier, with CCTV recovered by the police investigation showing the purchase of knives for use in the attack.

Adebowale

Adebolajo was the dominant one of the killers. Adebowale, from Greenwich, south London, was also a convert to Islam who had attended rallies held by successor groups to al-Muhajiroun. He attended one outside the US embassy in London as recently as September 2012.

Adebowale, who brandished a gun at police, had his thumb shot off by an armed officer.

Police do not know how the two men met, although they believe the pair attended various mosques in south London. One attended a community centre in Greenwich which held prayer sessions.

Adebowale's mother was a probation worker and his father worked for the Nigerian high commission in London. He showed an interest in studying at a community college in Greenwich, but never enrolled.

Like his accomplice, he was in trouble with the police as a youth. Adebowale is suspected of being a former member of a London street gang and in 2008 was sentenced to 15 months in prison for involvement in drugs supply.

He dabbled in supplying minor drugs and ran away from home on at least two occasions. He spent four days in Feltham young offender institution.

As a teenager, Adebowale witnessed a murder and in January 2008, when he was 16, he was stabbed in a frenzied attack in which one person died. The incident gives an insight into a life in chaos.

Faridon Alizada, 18, was "literally cut to pieces" by an assailant wielding a 12-inch knife, according to the judge at the trial that followed the incident on a housing estate in Erith, south-east London. Lee James, 32, was convicted of murdering Alizada, stabbing a 16-year-old in the neck, and stabbing Adebowale in the shoulder and hand.

The trial at Southwark crown court heard that James, a former bare-knuckle fighter, accused Adebowale and the other youths, who were Afghans, of being members of al-Qaida and plotting to carry out explosions. The court heard claims that James was suffering from drug-induced psychosis during the attack.

Adebolajo and Adebowale arrive at the Old Bailey during the trial in a high-security armed Met police convoy. Photograph: Guy Corbishley/Demotix/Corbis

A Greenwich neighbour said that after the attack Adebowale disappeared for a year and converted to Islam, and that his character appeared to have changed.

Madeleine Edwards, a family friend who lived in the same block of flats as Adebowale in Greenwich, said he had been involved with a local gang – the Woolwich boys – when he was a young teenager and had been in "some serious gangland trouble".

She claimed his mother had said he had to "disappear for a while". He left for about a year and on his return was a convert to Islam and had become distant.

Adebowale suffered psychological problems from the attack, with psychologists who assessed him during the trial saying he still heard the voice of his attacker. His mental health problems had been exacerbated by the excessive smoking of skunk, a strong form of cannabis. Adebowale's mental health led to the trial being delayed and, as it deteriorated during the hearing, the decision was made that he could not testify in his own defence.

Adebowale suffered from psychotic episodes during his time in custody and, it is believed, heard voices beforehand. One spoke to him in a Nigerian accent and would predict what he was about to do next, he told psychiatrists, such as predicting he would brush his teeth.

He had episodes of hallucinations that left him out of touch with reality.

Adebowale had psychotic symptoms before the attack, and psychiatrists said he felt his religion protected him, or at least lessened the terrifying effects of the psychosis.

At times he believed spirits called Djinns would make him do things and were "playing with him". One psychiatrist said it was a way for Adebowale to rationalise his symptoms as he complained the Djinns were changing words on paper as he tried to read them.

In one evaluation, Dr Phillip Joseph, who assessed him for the Crown, said Adebowale hinted the Djinns were "partly responsible" for his involvement in the attack, and then backtracked.

He feared the Djinns could travel and might hurt his mother.

The psychiatrist Neil Boast said that during an assessment on 11 November Adebowale said he was a Christian and not a Muslim.

His police interviews were not admitted as evidence. Though he was assessed as fit to be interviewed, the judge decided he had been too unwell. One source with knowledge of the interviews described him as "bouncing off the walls", and saying bizarre things. In his first interview Adebowale lashed out at detectives, spitting on them, before being physically restrained.

In the weeks before the attack the two men were in frequent contact. Extremist material was recovered from their homes, including sermons from Anwar al-Awlaki, one of most effective propagators of the al-Qaida-inspired message on the web. The extremist material found was still available on YouTube as Adebolajo and Adebowale stood trial.

Adebowale, left, and Adebolajo at the scene. Photograph: Reuters

The two murderers behind the first Islamist attack in Britain to claim a life since 2005 are believed to have acted alone. The self-styled soldiers face life sentences after being convicted by a jury of their peers. They have left their families, the family of Lee Rigby and their communities to do the most difficult work, of grieving and healing. Few will see the bravery in that.