Image caption British security forces have been accused of involvement in dozens of murders during the Troubles in Northern Ireland

British security forces had thousands of agents and informants working inside Northern Ireland paramilitary groups, the BBC's Panorama has learned.

The undercover operatives were recruited by the Army, MI5 and Special Branch and many were involved in criminality and murder.

Ex-Met Police commissioner Lord Stevens said the agents caused huge problems in Northern Ireland.

The government says collusion with paramilitaries should never happen.

Lord Stevens led three government investigations into the security forces in Northern Ireland and has revealed the scale of the counter-intelligence operation for the first time.

Lord Stevens also told BBC Panorama that thousands of agents and informants were recruited during the Troubles, and that just one of the agents - Brian Nelson - may be linked to "dozens and dozens" of murders.

Image caption Baroness O'Loan says certain people were allowed to go on committing crimes

Nelson, who was a paid army agent, provided assassination targets for the three main Loyalist paramilitary groups - the Ulster Freedom Fighters, the Ulster Volunteer Force and the Red Hand Commando.

During his investigations in Northern Ireland, Lord Stevens and his team arrested 210 paramilitary suspects. He says that 207 of them were agents or informants for the state.

Crime 'impunity'

Baroness Nuala O'Loan, who was Northern Ireland's first police ombudsman, also found evidence that state agents were involved in murder.

She tells Panorama that the security forces failed to control their undercover operatives.

"They were running informants and their argument was that they were saving lives, but hundreds and hundreds of people died because these people were not brought to justice," she said.

"There was impunity really for these people to go on committing their crimes. Many of them were killers, some were serial killers."

One Special Branch agent in north Belfast has been linked to 20 murders.

Mark Haddock, who ran one of the Ulster Volunteer Force's most notorious terror gangs, was paid at least £79,000 for his work as a police agent.

Image caption Chief Constable George Hamilton agreed to release sensitive intelligence files

The police ombudsman of Northern Ireland is currently investigating 60 murder cases where the state has been accused of involvement.

These investigations were delayed because the police refused to hand over crucial evidence to the ombudsman.

But following a court challenge last year, the new Chief Constable George Hamilton agreed to hand over the intelligence files.

He told the programme that he was willing to work with the ombudsman, but the information needs to be handled carefully.

"There is a need to understand the sheer magnitude of what we are dealing with. We are talking about rooms full of material.

"Some of it is very sensitive, some of which if it is released in the wrong circumstances would be outside of legislation, some of it if released in the wrong circumstances could put lives at risk."

The government says that the vast majority of those who served in the security forces did so with distinction. It says collusion with paramilitaries should never happen and the government has apologised where it did.

Panorama: Britain's Secret Terror Deals is on BBC One at 21:00 BST on Thursday 28 May 2015 and available later via BBC iPlayer.