A secret UK-Libyan rendition programme in which two Libyan opposition leaders were kidnapped and flown to Tripoli along with their families had the effect of strengthening al-Qaida, according to an assessment by the UK security service, MI5.

Prior to their kidnap, Abdel Hakim Belhaj and Sami al-Saadi had ensured that their organisation, the Libyan Islamic Fighting Group (LIFG), focused on the overthrow of Colonel Gaddafi, the classified assessment says. Once handed over to the Gaddafi regime, their places at the head of the LIFG were taken by others who wanted to bring the group closer to al-Qaida.

The two men were seized in Thailand and Hong Kong in March 2004 with the assistance of the UK’s intelligence service MI6, and were “rendered” to Tripoli along with Belhaj’s pregnant wife and Saadi’s wife and four children, the youngest a girl aged six.

In an assessment made 11 months later, MI5 concluded that the capture of the pair had cast the group “into a state of disarray”, adding: “While these senior-ranking members have always jealously guarded the independence of the LIFG, providing it with a clear command structure and set goals, the group is now coming under pressure from outside influences.

“In particular, reporting indicates that members including Abu Laith al-Libi and Abdallah al-Ghaffar may be pushing the group towards a more pan-Islamic agenda inspired by AQ [al-Qaida].”

Two years after MI5 made this assessment, Libi announced the LIFG had formally joined forces with al-Qaida. He became a leading member of the merged organisation and is believed to have orchestrated a series of suicide bomb attacks across Afghanistan, including one in 2007 that killed 23 people at Bagram airfield north of Kabul during a visit by then US vice-president Dick Cheney. Libi was killed in a drone strike the following year.

The classified MI5 intelligence assessment was among hundreds of highly sensitive Libyan and British files that were discovered in official buildings that had been abandoned during the 2011 revolution that led to the overthrow and death of Muammar Gaddafi.

The end of his 42-year dictatorship was hastened by Nato air strikes, and was followed by a period of brief and heady optimism. At a rally in Benghazi in the east of the country in September 2011, the British prime minister, David Cameron, and the French president, Nicolas Sarkozy, addressed enormous crowds waving their countries’ flags. “It’s great to be here in free Benghazi and in free Libya,” Cameron told them.

But Libya’s new leadership was already struggling to impose its authority on the country. And since then, the country has descended into violence and economic instability, with rival militias shelling residential areas and destroying infrastructure in their fight for supremacy.

Fears that Islamist militants would fill the yawning power vacuum appeared to be realised on Tuesday when gunmen claiming allegiance to Islamic State said that they were responsible for an attack on a Tripoli hotel in which at least five guards and five foreigners were killed.

The papers that were recovered during the revolution show that Britain’s intelligence agencies engaged in a series of joint operations with Gaddafi’s government and that some of the information extracted from victims of rendition was used as evidence during control-order and deportation proceedings in UK courts.

They also show that in 2006, Libyan intelligence agents were invited to operate on British soil, where they worked alongside MI5 and allegedly intimidated a number of Gaddafi opponents who had been granted asylum in the UK.

Another of the recovered documents is a letter that Tony Blair wrote to Gaddafi in April 2007, and whose existence publicly emerged last week. Addressed “Dear Mu’ammar”, Blair expressed his regret that the British government had failed in its attempts to have a number of Gaddafi’s opponents deported from the UK, and thanked the dictator for his intelligence agencies’ “excellent co-operation” with their British counterparts.

The classified MI5 document was prepared in advance of a five-day visit to Tripoli by senior agency staff in February 2005. Marked “UK/Libya Eyes Only – Secret”, it explains that members of the LIFG had been permitted to settle in the UK in the 1990s. This was at a time when Gaddafi, whom the group was plotting to overthrow, was considered to be an enemy of Britain.

The document adds that MI5 reassessed the LIFG’s UK-based members following the change in the group’s leadership that resulted from the detention of Belhaj and Saadi.

“We are actively investigating key individuals in the UK and are seeking to disrupt their activities,” the document says. This action was part of a new strategy “for countering the threat from the LIFG to the UK and its allies” – allies which, by 2005, included the Libyan dictatorship.

Accompanying the document was a list of questions that MI5 wanted Libyan interrogators to put to Belhaj and Saadi. A total of more than 1,600 questions were sent from the UK to Tripoli, in four batches, with MI6 at one point thanking the Libyan intelligence agents for “kindly agreeing” to pass the questions to their “interview team”.

Belhaj and Saadi both say they were beaten, whipped, subjected to electric shocks, deprived of sleep and threatened while being held at Tajoura prison outside Tripoli.

They say they were also interrogated by British intelligence officers, and Belhaj says he made it clear, by sign language, that he was being tortured.

After one of these encounters, he says, he agreed to sign a statement about his associates in the UK to avoid being subjected to a form of torture called the Honda, which involved being locked in a box-like structure whose ceiling and walls could be shrunk.

The discovery of the documents that exposed the existence of the UK-Libyan rendition operations had caused widespread dismay in Westminster, even before the emergence of the latest report, which makes clear that one consequence of these operations was that the terrorist organisation that posed the greatest threat to the UK at that time was strengthened.

A criminal investigation into the affair was opened in January 2012 after Dominic Grieve, the then attorney general, wrote to the Metropolitan police commissioner, Bernard Hogan-Howe. After a three-year investigation codenamed Operation Lydd, detectives handed their report to the Crown Prosecution Service last month.

Jack Straw, who was foreign secretary at the time, is among the people who have been questioned by police. His office says he was interviewed as a witness.

The rendition operations also led to damages claims being brought by Saadi – who received £2.2m in compensation from the British government – and by Belhaj. Belhaj is claiming damages on behalf of himself and his wife. She was four-and-a-half months pregnant when the couple were kidnapped, and Belhaj says she was taped, head to foot, to a stretcher for the 17-hour flight to Tripoli, before being jailed for several months.

Belhaj says he would settle his claim for just £3, as long as he and his wife also receive an apology. With the CPS currently considering the police file, this is unlikely to happen.