Image caption UK resident Binyam Mohamed claims MI5 knew about his torture

David Cameron has said a "judge-led" inquiry will look at claims that UK security services were complicit in the torture of terror suspects.

The prime minister promised compensation for victims if it was found foreign agents had committed abuses with UK counterparts colluding.

Mr Cameron told MPs that to ignore the claims would risk operatives' reputation "being tarnished".

On-going criminal and civil cases must end before the inquiry starts, he said.

The "fully independent" investigation, chaired by former Appeal Court judge Sir Peter Gibson, would start before the end of the year and report within a year, the prime minister added.

The Conservatives and Liberal Democrats have long called for an investigation into the claims by Ethiopian-born UK resident Binyam Mohamed that UK security services were aware of his torture by foreign interrogators, who were allegedly fed questions via the CIA.

Mr Cameron told MPs: "For the past few years the reputation of our security services has been overshadowed by allegations about their involvement in the treatment of detainees held by other countries.

"Some of those detainees allege they were mistreated by those countries. Other allegations have also been made about the UK's involvement in the rendition of detainees in the aftermath of 9/11.

"These allegations are not proven but today we do face a totally unacceptable situation. Our services are paralysed by paperwork as they try to defend themselves in lengthy court cases with uncertain rules.

An inquiry done well can help ensure that British abuses are not repeated and restore Britain's reputation Tom Porteous, Human Rights Watch Q&A: UK torture inquiry

"Our reputation as a country that believes in human rights, fairness and the rule of law - indeed for much of what the services exist to protect - risks being tarnished."

The panel conducting the inquiry would have access to all relevant papers, the prime minister promised, with some proceedings held in public.

He indicated the government was ready to provide mediation to people pursuing civil cases in relation to their detention in the US-run Guantanamo Bay detention camp.

The prime minister's spokesman acknowledged the inquiry would have access only to UK papers and personnel - not those of other countries such as the US.

Labour leader Harriet Harman supported the inquiry, saying that any incidents of torture were "morally abhorrent" and a "grave crime against humanity".

She added: "There must be no hiding place for those who practise it and no excuse for those who turn a blind eye.

"The United Kingdom should always be at the forefront of international efforts to detect and expose torture, and to bring those responsible for it to justice."

'Stitch-ups'

Mr Mohamed says he was tortured after being held in Pakistan in 2002, and subsequently moved to Morocco and Afghanistan.

He maintains the only evidence against him was obtained through such methods. Mr Mohamed also says agents from the UK's MI5 knew about this and fed questions to his interrogators through the CIA.

But UK security services say they do not use or condone torture and the government is publishing the guidance to the UK security services, including a directive not to take any action which they know or believe could lead to torture by operatives from abroad.

Shami Chakrabarti, director of Liberty, said: "An inquiry into British complicity in torture is welcome and overdue but this announcement leaves room for fears that government is bending towards the security establishment.

"They wouldn't be in this mess but for all the excuses for secret stitch-ups instead of open justice."

Tom Porteous, UK director of Human Rights Watch, said: "This inquiry must be demonstrably independent, comprehensive and to the greatest extent possible public.

"An inquiry done well can help ensure that British abuses are not repeated and restore Britain's reputation as an anti-torture champion. The publication of the guidance is a welcome step. We will examine the details closely."