Secret files have been unearthed by The Independent in Tripoli that reveal the astonishingly close links that existed between British and American governments and Muammar Gaddafi.

The documents chart how prisoners were offered to the Libyans for brutal interrogation by the Tripoli regime under the highly controversial "rendition" programme, and also how details of exiled opponents of the Libyan dictator in the UK were passed on to the regime by MI6.

The papers show that British officials actually helped write a draft speech for Colonel Gaddafi while he was trying to rehabilitate his regime from the pariah status to which it had sunk following its support for terrorist movements. Further documents disclose how, at the same time, the US and UK acted on behalf of Libya in conducting negotiations with the International Atomic Energy Agency.

With the efforts they had expended in cultivating their contacts with the regime, the British were unwilling, at times, to share their "Libya connection" with the closet ally, the US. In a letter to his Libyan intelligence counterpart, an MI6 officer described how he refused to pass on the identity of an agent to Washington.

The documents, many of them incendiary in their implications, were found at the private offices of Moussa Koussa, Col Gaddafi's right hand man, and regime security chief, who defected to Britain in the days following the February revolution.

The papers give details about Tony Blair's visit to the Libyan dictator in Tripoli - with the vignette that it was the British prime minister's office that requested that the meeting take place in a tent. A letter from an MI6 official to Mr Koussa stated "No 10 are keen that the Prime Minister meet the Leader in the tent. I don't know why the English are fascinated by tents. The plain fact is that the journalists would love it."

The material raises questions about the relationship between Moussa Koussa and the British government and the turn of events following his defection. Mr Koussa's surprising arrival in Britain led to calls for him to be questioned by the police about his alleged involvement in murders abroad by the Libyan regime, including that of policewoman Yvonne Fletcher and opponents of Gaddafi. He was also said to be involved in the sending of arms to the IRA. At the time David Cameron's government assured the public that Mr Koussa may, indeed, face possible charges. Instead, he was allowed to leave the country and is now believed to be staying in a Gulf state.

The revelations by The Independent will lead to questions about whether Mr Koussa, who has long been accused of human rights abuses, was allowed to escape because he held a 'smoking gun'. The official is known to have copied and taken away dozens of files with him when he left Libya.

The papers illustrate the intimate relations Mr Koussa and some of his colleagues seemingly enjoyed with British intelligence. Letters and faxes flowed to him headed 'Greetings from MI6' 'Greetings from SIS', handwritten Christmas greetings, on one occasion, from ' Your friend', followed by the name of a senior British intelligence official, and regrets over missed lunches. There were also regular exchanges of gifts: on one occasion a Libyan agent arrived in London laden with figs and oranges.

The documents repeatedly touched on the blossoming relationship between Western intelligence agencies and Libya. But there was a human cost. The Tripoli regime was a highly useful partner in the 'rendition' process under which prisoners were sent by the US for 'enhanced interrogation', a euphemism, say human rights groups, for torture.

One US administration document, marked secret, says "Our service is in a position to deliver Shaykh Musa to your physical custody similar to what we have done with other senior LIFG (Libyan Islamic Fighting Group) members in the past. We respectfully request an expression of interest from your service regarding taking custody of Musa".

The British too were dealing with the Libyans about opposition activists, passing on information to the regime. This was taking place despite the fact that Colonel Gaddafi's agents had assassinated opponents in the campaign to eliminate so-called "stray dogs" abroad, including the streets of London. The murders had, at the time, led to protests and condemnation by the UK government.

One letter dated 16th April 2004 from UK intelligence to an official at the International Affairs Department of Libyan security, says: "We wish to inform you that Ismail KAMOKA @ SUHAIB [possibly referring to an alias being used] was released from detention on 18th March 2004. A panel of British judges ruled that KAMOKA was not a threat to national security in the UK and subsequently released him. We are content for you to inform [a Libyan intelligence official] of KAMOKA's release."

Ironically, the Libyan rebels who have come in to power after overthrowing Colonel Gaddafi with the help of the UK and NATO have just appointed Abdullah Hakim Belhaj (please check spelling), a former member of the LIFG, as their commander in Tripoli.

Other material highlights the two-way nature of the information exchange. One document headed "For the attention of the Libyan Intelligence Service. Greetings from MI6 asks for information about a suspect with the initials ABS [full name withheld from publication for security reasons] travelling on Libyan passport number 164432.

"This remains a sensitive operation and we do not want anything done that might draw S's attention to our interest in him. We would be grateful for any information you might have regarding S."

One of the most remarkable finds in the cache of documents is a statement by Colonel Gaddafi during his rapprochment with the West during which he gave up his nuclear programme and promised to destroy his stock of chemical and biological weapons.

The Libyan leader said "we will take these steps in a manner that is transparent and verifiable. Libya affirms and will abide by commitments... when the world is celebrating the birth of Jesus, and as a token of contribution to a world full of peace, security, stability and compassion the greater Jamhiriya renews its honest call for a WMD free zone in the Middle East and Africa."

The statement was, in fact, put together with the help of British officials. A covering letter, addressed to Khalid Najjar, of the Department of International Relations and Safety in Tripoli, said "for the sake of clarity, please find attached a tidied up version of the language we agreed on Tuesday. I wanted to ensure that you had the same script."

When Libya's high command expressed worries about how abandoning their WMD arsenal would leave them vulnerable, the UK proposed helping to bolster conventional defences using Field Marshall Lord Inge, a former head of the UK military as a consultant. In a letter from London dated 24th December 2003, a British official wrote: "I propose that Field Marshal Lord Inge, whom you will remember well from September, should visit two or three senior officers to start these talks."

"No. 10 are keen that the Prime Minister meet the leader in his tent"

*A sizeable amount of correspondence in the cache was devoted to the visit of Tony Blair to meet Muammar Gaddafi in March 2004 at a time when Britain was playing a key role in bringing Libya in from the cold.

The documents show how involved MI6 was with organizing the trip and the role of conduit played by Moussa Koussa. Unsurprisingly for the Blair administration, presentation was seen as of paramount importance.

An MI6 officer wrote to Mr Koussa, saying: "No.10 are keen that the Prime Minister meet the leader in his tent. I don't know why the English are fascinated by tents. The plain fact is the journalists would love it. My own view is that it would give a good impression of the Leader's preference for simplicity which I know is important to him. You may have seen very different press conference in Riyadh. Anyway, if this is possible, No.10 would be very grateful."

Colonel Gaddafi, apparently, had wanted to meet the British Prime Minister at Sirte, his birth place. At present the town is under siege from opposition fighters. The MI6 officer states: "No.10 are expecting that the visit will take place in Tripoli and not Sirte. Apparently it is important that the journalists have access to hotels and so on where there may be facilities for them to file their stories to their newspapers."

However, the spies were there to make sure that their and the national interests was being protected. The officer continued, "No.10 have asked me to accompany the Prime Minister so I am very much looking forward to seeing you next Thursday. No.10 have asked me whether I could put an officer into Tripoli a few days before the visit... I think this would give them comfort and everything would work out well."