The attorney general has given a pledge that no one will face prosecution based on evidence given at the inquiry into undercover policing.

The assurance means former officers will not be prosecuted for on anything they say during the inquiry.

In a letter to the inquiry chairman, Attorney General Jeremy Wright QC said the evidence would also not be used in charging decisions.

The inquiry said all witnesses could now appear "without fear".

Campaigners against alleged wrongdoing by former officers have called for some of them to face criminal investigations. One officer, Mark Kennedy, was undercover inside environmental groups - and the discovery of his involvement in a power station protest led to the convictions of 20 protesters being successfully appealed.

Separately, Scotland Yard said earlier this year it was reinvestigating a 1987 firebomb attack after an allegation in Parliament that it was planted by another former undercover officer.

Both these former officers, and others, are expected to appear at the inquiry, which will not begin to hear evidence from witnesses until 2017.

The attorney general said he had agreed to the immunity request from the inquiry chair, which would cover all evidence and hearings in the inquiry.

The letter says no evidence given in person or by written statement - whether it be materials used in the inquiry or simply as part of its preparations - will be used "against him or her or their spouse or civil partner in any criminal proceedings whether present or future or on appeal from a conviction".

The only exemption would be if someone faced a perjury allegation by having given false evidence, the letter says.

"For the avoidance of doubt, this undertaking does not preclude the use of a document and or information and or evidence identified independently of the evidence provided by that person to the inquiry," it adds.

In a press statement, the inquiry said the letter would "enable witnesses to give evidence to the Inquiry without fear of being investigated and prosecuted as a result of their own evidence."