Talking to terrorists and dictators is "necessary" says the former head of the security service MI5.

Eliza Manningham-Buller singled out the British government's engagement with Colonel Gaddafi in 2003, saying it was the "right decision".

In the third of her BBC Radio Reith lectures, she added "the prize was the abandonment of his programme for nuclear weapons".

She said "talking does not mean approval" but may "reduce the threat".

Baroness Manningham-Buller's 2011 Reith Lectures examine the issues of terrorism, security and foreign policy strategy since the 9/11 attacks on the US 10 years ago.

Speaking on the British government's decision to engage with Libya's Colonel Gaddafi in 2003 she acknowledged it was "difficult... but the right decision to open talks".

"Had Gaddafi made progress with his nuclear programme he could still be in power today and threatening us."

I know that protecting British citizens would be impossible if we were restricted to talking to those with values we share Eliza Manningham-Buller, Former director general, MI5

The former director general of MI5, who retired from the service in 2007, also stressed that while it is important for governments to engage with autocratic regimes, they should not become complacent.

"We should never forget who and what they are. We need to avoid helping dictators survive. The West's record on that is poor.

"We have too often preferred the stability of the devil we know, to the uncertainties of democracy."

Acknowledging recent allegations claiming the British Secret Intelligence Service, MI6, formed close ties with their Libyan counterparts, Eliza Manningham-Buller said there are questions to be answered about the relationships that developed with Libya since the decision was made to bring Col Gaddafi in from the cold.

However she anticipates the on-going detainee inquiry led by Sir Peter Gibson will address these issues.

In her third and final Reith lecture, recorded at the British Library in London, she said developing a dialogue not only with dictators, but also with terrorists was integral to reducing the threat of terrorist attacks.

"From my own perspective in the Security Service, I know that protecting British citizens would be impossible if we were restricted to talking to those with values we share."

"Look at Northern Ireland, where former terrorists are in government... look at [Nelson] Mandela and the ANC which used terror tactics when it was in exile."

"We should welcome this, not damn it."

However, the ex-MI5 head does not think such a strategy will be easy:

"I am not naive about al-Qaeda. I don't see Ayman al-Zawahiri turning up at a conference table anytime soon.

"But I think there are components [of al-Qaeda] you could talk to".

Baroness Manningham-Buller's comments coincide with recent reports that the US government has endorsed plans for the Taliban to open political headquarters in the Gulf state of Qatar by the end of the year.