Image copyright Other

British efforts to help topple Colonel Gaddafi were not limited to air strikes. On the ground - and on the quiet - special forces soldiers were blending in with rebel fighters. This is the previously untold account of the crucial part they played.

The British campaign to overthrow Muammar Gaddafi's regime had its public face - with aircraft dropping bombs, or Royal Navy ships appearing in Libyan waters, but it also had a secret aspect.

My investigations into that covert effort reveal a story of practically minded people trying to get on with the job, while all the time facing political and legal constraints imposed from London.

In the end, though, British special forces were deployed on the ground in order to help the UK's allies - the Libyan revolutionaries often called the National Transitional Council or NTC. Those with a knowledge of the programme insist "they did a tremendous job" and contributed to the final collapse of the Gaddafi regime.

Image copyright Other Image caption Multiple radios indicate sophisticated coordination of forces

The UK's policy for intervention evolved in a series of fits and starts, being changed at key points by events on the ground. The arguments about how far the UK should go were thrashed out in a series of meetings of the National Security Council at Downing Street. Under the chairmanship of Prime Minister David Cameron, its key members were:

Chief of the Defence Staff General Sir David Richards

Defence Secretary Liam Fox

Foreign Secretary William Hague

Mr Cameron's chief of staff, Ed Llewellyn, was a key voice in urging action following start of the Libyan revolution last February, say Whitehall insiders.

Secret unit within the special forces Image copyright Getty Images The existence of E Squadron is well known within the special forces community but has not hitherto been discussed publicly. It was formed five years ago to work closely with the intelligence service MI6, and is mainly involved in missions where maximum discretion is required, say Whitehall insiders. Its role as a small, handpicked force operating with MI6 makes it the modern-day successor to the shadowy cell sometimes referred to as the Increment. While the existence of teams of this kind is a gift for thriller writers looking to insert a hit team of hardened SAS men into their plotline, the reality of E Squadron's operations has been a little more prosaic. Last March's debacle, in which six members of the squadron were caught in Libya, was highly embarrassing. The reason for their presence, escorting two people from MI6, gives a clue to the facilitating role they often play in foreign intelligence operations in risky places. After 9/11, with major military commitments in Afghanistan and then Iraq, MI6 stepped up its intelligence-gathering in many places that had hitherto been off the radar or considered too dangerous. It was often backed up by UK special forces, but the competing demands on them to support special operations in Afghanistan and Iraq eventually led to the creation of E Squadron. According to special forces people, E Squadron is a composite organisation formed from selected SAS, SBS and Special Reconnaissance Regiment operators. It is not technically part of the SAS or SBS, but at the disposal of the Director of Special Forces and MI6. The squadron often operates in plain clothes and with the full range of national support, such as false identities, at its disposal. Whitehall sources suggest E Squadron was prepared to launch a rescue of a British citizen kidnapped in the Sahara in 2009, but could not obtain political clearance to do so before he was murdered by the hostage-takers.

The first significant involvement of British forces inside Libya was a rescue mission mounted just a couple of weeks after the rising against Gaddafi broke out. On 3 March, Royal Air Force C130 aircraft were sent to a desert airstrip at Zilla in the south of the country to rescue expatriate oil workers. Many had been threatened by gunmen and bandits.

This airlift of 150 foreigners, including about 20 Britons, to Valletta airport in Malta went smoothly, despite one of the aircraft being hit by ground fire soon after taking off.

Accompanying the flights were about two dozen men from C Squadron of the Special Boat Service (SBS), who helped secure the landing zone. It was a short-term and discreet intervention that saved the workers from risk of abduction or murder, and caused little debate in Whitehall.

Events, though, were moving chaotically and violently onwards, with the Libyan armed forces breaking up and Benghazi emerging as the centre of opposition. The government sought to open contacts with the National Transitional Council both overtly and covertly.

It was the undercover aspect of this relationship that almost brought Britain's wider attempt to help the revolution to grief. The Secret Intelligence Service, or MI6, sought to step up communications with some of its contacts in the opposition. It was decided to send a pair of the service's people to a town not far from Benghazi to meet one of these Libyans.

MI6, say people familiar with what happened, decided to avoid the Royal Navy frigate in Benghazi at the time, or any other obvious symbol of national power as the base for this meeting. Instead, they opted to be flown from Malta into Libya at night by Chinook helicopter in order to meet local "fixers" who would help them get to the meeting.

In planning this operation, SIS chose to use a highly sensitive arm of the special forces, E Squadron, in order to look after its people. Six members of E Squadron, which is recruited from all three Tier 1 units (SAS, SBS and Special Reconnaissance Regiment) duly boarded the Chinook to "mind" the intelligence people.

They were equipped with a variety of weapons and secure communications gear. In keeping with E Squadron's sensitive role, they were in plain clothes or black jumpsuits (accounts vary), and carried a variety of passports.

Witnesses said they were carrying weapons, ammunition, maps and passports from four different countries SAS 'captured near Benghazi'

The plan unravelled almost immediately. The landing of their helicopter aroused local curiosity.

The Libyan revolution, like many others, was accompanied by a good deal of paranoia about foreign mercenaries and spies, and the British party could not have appeared more suspicious. They were detained and taken to Benghazi, the men on the ground having decided that to open fire would destroy the very bridge-building mission they were engaged in.

This debacle in Benghazi rapidly became even more embarrassing, as the Gaddafi government released an intercepted phone call in which a British diplomat pleaded with the NTC for the team's release.

As a result of what happened with E Squadron, those who would advocate using special forces to help topple the regime were sidelined for months. It also caused great difficulties for MI6, which had plans to turn some key figures in Gaddafi's inner circle.

When, on 19 March, Colonel Gaddafi's tanks were bombed as they entered Benghazi, the conflict entered a dramatically different phase. High-profile military action was under way, and the leaders of the UK, US, and France were increasingly committed to the overthrow of the Libyan leader.

Media playback is unsupported on your device Media caption Ambassador Richard Northern's phone call was played on Libyan State TV

But the means that could be used would be tightly limited as a result both of the unhappy experience of Iraq, and the terms of the UN resolution that had authorised the air action.

Under UN Security Council Resolution 1973, countries were authorised to use force "to protect civilians and civilian populated areas under threat of attack". The text noted that the measures used to achieve this aim excluded "a foreign occupation force of any form on any part of Libyan territory".

The resolution authorised force but its limitations, both in avoiding any mention of support to forces fighting Col Gaddafi's army and apparently in ruling out "boots on the ground", defined much of British government thinking.

Yet key figures in the Downing Street discussions were convinced that air strikes alone would not achieve the result they wanted. At sessions of the National Security Council, Gen Richards and Mr Fox made the case for planning to provide training and equipment for the revolutionary forces of the NTC.

At a meeting near the end of March, we have been told, authorisation was given to take certain steps to develop the NTC's embryonic ground forces. This involved the immediate dispatch of a small advisory team, and the longer-term development of a "train and equip" project. Ministers were advised, say those familiar with the discussion, that this second part of the plan would take at least three months to implement.

Media playback is unsupported on your device Media caption Watch Mark Urban's report on the secret war

When half a dozen British officers arrived at a seaside hotel in Benghazi at the beginning of April, they were unarmed and their role was strictly limited. They had been told to help the NTC set up a nascent defence ministry, located in a commandeered factory on the outskirts of the city.

The first and most basic task of the advisory team was to get the various bands of Libyan fighters roaring around in armed pick-up trucks under some sort of central co-ordination. As reporters had discovered, most of these men had little idea of what they were doing, and soon panicked if they thought Col Gaddafi's forces were attacking or outflanking them.

There were a number of legal issues preventing them giving more help. Some Whitehall lawyers argued that any type of presence on the ground was problematic. Legal doubts were raised about arming the NTC or targeting Col Gaddafi.

Once the air operation was put on a proper Nato footing, these issues became even more vexed, insiders say, with the alliance saying it would not accept men on the ground "directing air strikes" in a way that some newspapers, even in late spring, were speculating was already happening.

The British government's desire to achieve the overthrow of Gaddafi while accommodating the legal sensitivities registered by various Whitehall departments led to some frustration among those who were meant to make the policy work.

Image copyright Other Image caption Misrata rebels used sophisticated range-finders to adjust artillery fire and co-ordinate Nato air strikes

"It just seemed to me an unnecessarily muddled way of going about a business that we all knew the underlying aims of," said one. "It was almost as if we have lost the ability to define a clear objective and go for it."

However, the accidental bombing of NTC columns by Nato aircraft in early April provided those who wanted more direct assistance with a powerful argument. British and French officers on the ground were permitted to co-ordinate more closely with the NTC for the purposes of "deconfliction" or preventing such accidental clashes from happening again.

Under the deconfliction rubric, British advisers made their way to places like Misrata, then under siege, where the RAF was focusing its air strikes. The stage was set then for months of bombing which, as it progressed, both exhausted the stocks of precision weapons available to some Nato allies and the patience of many politicians for what was going on. Insiders say that, discreetly, they were soon doing more than deconfliction, actually co-ordinating certain Nato air attacks.

Taking as his cue the March approval in principle for a training programme, Gen Richards had started a series of low profile visits to Doha, the capital of Qatar.

This Gulf emirate had taken a leading role in backing the NTC, and its defence chief was by June brokering an agreement with the UK and France to provide material back-up as well as training for the NTC.

Image copyright bbc

The fall of Gaddafi told through maps

France was to prove more forward-leaning than the UK in this, and by August was providing weapons to NTC units in the Nefusa mountains of western Libya. The UK, meanwhile, had agreed to focus its efforts in the east of the country. It was as part of this new effort that British special forces returned to Libya.

Although plenty of people in Whitehall still remembered the March debacle, it was agreed to allow a limited number of British advisers to take a direct part in training and mentoring NTC units in Libya. Sources say the number of men sent from D Squadron of 22 SAS Regiment was capped at 24. They were performing their mission by late August.

While France and Qatar were ready to provide weapons directly, the UK was not. However, this made little practical difference since the SAS was operating closely with Qatar special forces who had reportedly delivered items such as Milan anti-tank missiles.

Image copyright Other Image caption Anti-tank missile in Sirte, of the type believed to have been supplied by Qataris

There were some suggestions from Whitehall that the training itself should be conducted outside Libya in order to remain within the narrow interpretation of the UN resolution, but the SAS was apparently soon present at a base in southern Libya.

Decoding the special forces British Army's Special Air Service (SAS) , formed in 1941 to drop troops by parachute behind enemy lines. Main role of its 400 members is to gather intelligence on the ground, but also has history of tackling perilous engagements - most famously storming the Iranian embassy in London in 1980.

, formed in 1941 to drop troops by parachute behind enemy lines. Main role of its 400 members is to gather intelligence on the ground, but also has history of tackling perilous engagements - most famously storming the Iranian embassy in London in 1980. Special Boat Service (SBS) , formed in 1940, is Royal Navy's equivalent, and the two services have strong links. SBS specialises in operations at sea and on river networks, but sometimes operates inland.

, formed in 1940, is Royal Navy's equivalent, and the two services have strong links. SBS specialises in operations at sea and on river networks, but sometimes operates inland. Special Reconnaissance Regiment (SRR), formed in 2005. Few details of its function or personnel have been made public, but its main purpose is to carry out covert surveillance operations, freeing SAS and SBS for combat.

During the months that this project had taken to come to fruition, the slow grinding down of Gaddafi's forces by air attack had continued. Soon after the foreign trainers arrived, NTC units swept into Tripoli.

Some people close to the Libyan revolution say that the Qatari chief of defence staff claimed credit for coming up with the strategy of pushing simultaneously towards the Libyan capital from different directions. Certainly, the foreign special forces on the ground played a role in co-ordinating the different columns.

The SAS had meanwhile strayed beyond its training facility, with single men or pairs accompanying the NTC commanders that they had been training back to their units. They dressed as Libyans and blended in with the units they mentored, says someone familiar with the operation.

There had been concerns that they would be spotted by the press, but this did not happen. "We have become a lot better at blending in," says someone familiar with the D Squadron operation. "Our people were able to stay close to the NTC commanders without being compromised."

Instead, as the revolutionaries fought their way into Gaddafi's home town of Sirte, they were assisted by a handful of British and other special forces. Members of the Jordanian and United Arab Emirates armies had fallen in behind the Qataris too.

When, on 20 October, Gaddafi was finally captured and then killed by NTC men, it followed Nato air strikes on a convoy of vehicles carrying leading members of the former regime as they tried to escape from Sirte early in the morning. Had British soldiers on the ground had a hand in this? Nobody will say yet.

In keeping with its long standing policies on special forces and MI6 operations, Whitehall has refrained from public statements about the nature of assistance on the ground. The Ministry of Defence reiterated that policy when asked to comment on this story.

Speaking at a public event late last year, though, Gen Richards commented that the NTC forces "were the land element, an 'army' was still vital". He also noted that "integrating the Qataris, Emiratis and Jordanians into the operation was key". He did not, however, allude to the presence of more than 20 British operators on the ground.

We have become a lot better at blending in

Last October the Chief of the Qatar Defence Staff revealed that "hundreds" of his troops has been on the ground in Libya.

British sources agree Qatar played a leading role - and accept it put more soldiers in than the UK - but question whether the number was this large. Around the more secret parts of Whitehall, the suggestion is that the number committed on the ground by all nations probably did not exceed a couple of hundred.

As for Britain's decision finally to deploy an SAS squadron, "they made a fantastic difference", argues one insider.

It is part of the essence of troops of this kind that they often operate in secrecy, providing their political masters with policy options that they might not wish to own up to publicly.

But given that the UK's earlier relationship with Col Gaddafi and his intelligence services caused great embarrassment, it could be that attention will one day focus more closely on British assistance to the NTC, particularly if the Libyan revolution comes unstuck.

Watch Mark Urban's full report on BBC Two's Newsnight on Wednesday 18 January 2012 at 22:30 GMT, or catch up with the BBC iPlayer and Newsnight website.