Justice Secretary Chris Grayling has issued an apology to the House of Commons after revealing that telephone calls between prisoners and their constituency Members of Parliament or MPs' offices may have been recorded or listened to by prison staff.
Mr Grayling told MPs that an independent investigation would be carried out by the Chief Inspector of Prisons Nick Hardwick.
Speaking at the start of his ministerial statement, he said: "I want to inform the House that telephone calls between prisoners and their constituency Members of Parliament or MPs' offices may have been recorded and in some cases listened to by prison staff.
"This issue stretches back to 2006 and primarily relates to the period prior to autumn 2012 when this Government made changes to tighten up the system.
This is a serious matter and I would like to start by apologising to the House on behalf of my department for any interception of communications between a prisoner and their constituency MP."
Mr Grayling said the issue was first brought to his attention on November 5 and he had come to the House "at the earliest opportunity".
He said: "The prison rules and policy are clear that communication between prisoners and honourable members themselves must be treated as confidential where the prisoner is a constituent of theirs."
He said the National Offender Management Service had identified instances since 2006 when detailed audit records start where calls between prisoners and MPs' constituency and parliamentary offices had been set to record.
He said: "In a small number of cases those calls have been recorded and listened to by prison staff. From the initial investigation, NOMS has identified 32 current members of this House whose calls or those for their offices appear to have been both recorded and listened to.
"For 18 of these MPs it appears the prison did not list the number as confidential and therefore the action was not taken to prevent recording."
He added: "In a further 15 cases, members appear to have been identified correctly on the system as MPs, but due to a potential failure in the administrative process the required action was not taken by prison staff so the calls were recorded and appear to have been listened to, one member falls under both categories."
Mr Grayling said there is no evidence that information from the phone calls was passed on to anyone else and he did not believe it was part of a concerted attempt to monitor calls.
The Justice Secretary stressed it was part of the routine checking process and mistakes may have been made.
He told the Commons: "I have as yet seen no evidence that information was passed on to anyone else, I don't believe this was part of a concerted attempt to monitor, it was simply part of the routine checking of this process to make sure nothing untoward was going on.
"But clearly again, it's something I'll be asking Nick Hardwick to confirm."
Mr Grayling said he believed all recordings have now been destroyed as they are only kept for a limited period.
Since improvements to the system in autumn 2012, only one MP clearly identified on prison lists has had their calls with prisoners recorded and listened to, he added.
But there have been a small number of cases where phone calls between prisoners and lawyers were "accidentally recorded", Mr Grayling said.
He added: "Whilst these have been dealt with individually with the prisoner at the time, I want to be confident that the safeguards for all confidential calls are satisfactory."
Mr Grayling said Mr Hardwick will first report at the end of the month to ensure that safeguards to stop phone calls being recorded or listened to are in place before publishing a full assessment of the facts in early 2015.
Shadow justice secretary Sadiq Khan said the revelations were "truly shocking" and welcomed the investigation to be led by Mr Hardwick.
The Labour frontbencher pointed out that some of the conversations may have taken place with prisoners who had not yet been convicted of a crime.
He told the Commons: "What you have outlined in your statement is a very serious breach of confidentiality involving MPs and their constituents.
"Many of us in this House will deal with constituents in prison, many of which I remind the House have not been found guilty of any crimes, on a regular basis as part of our duties as good constituency MPs, often our staff speak to prisoners on our behalf as they do with other case work.
"I am sure I am not alone in being shocked in hearing today's news that some of these conversations have been listened into, that some of these conversations have been listened into and recorded.
"That's why it is important, as the Justice Secretary said, we get to the bottom of this as quickly as possible, find out the extent to which it was taking place, and put in place a system that prevents a repeat in the future."
Mr Khan said questions remained over whether privately-run prisons were involved, how many prisons were involved and how many former MPs had their phone calls listened to.
Mr Grayling said the most recent call recorded was the constituency office of his colleague Lib Dem minister of justice and civil liberties Simon Hughes (Bermondsey and Old Southwark) where a prisoner spoke to a member of the constituency office rather than Mr Hughes to inquire about the progress of some constituency correspondence.
He said: "In each case it is important to understand whether the prisoners were speaking to an MP directly, rather than their office, and whether that MP was their constituency MP. These are relevant questions if we are to get to the bottom of what has gone on.
"I must say that I have seen nothing to suggest that there has been an intentional strategy of the Prison Service listening into calls between prisoners and individual Members of Parliament."
Referring to former Labour justice secretary Jack Straw, he added: "In the case of the right honourable member for Blackburn, who was one of my predecessors, his calls were being recorded and listened to at a time when he was the secretary of state, it does appear that this issue appears to have arisen by accident rather than by design."
He went on: "That is not however to detract from the fact that confidential phone calls between members of this House themselves and their constituents in prison may have been recorded and monitored.
"It is unacceptable and I want to ensure that we have taken every reasonable step to protect the confidentiality of communications between prisoners and their consistency MPs."
In backbench exchanges, Mr Straw apologised for the phone calls listened to while he was justice secretary but said all the calls involving his office were conducted by members of his staff.
He said this showed that the monitoring by prison staff was probably an inadvertent mistake.
Mr Straw said: "I was in office for three of those six years and I feel it appropriate for me to offer an apology for what happened on my watch.
"I am grateful to you for giving me prior information about the fact that five or six calls were made to my office whilst I was justice secretary.
"I think at all material times I had an alibi that I was not on the end of the calls because I was either in the House of Commons or in the justice ministry and it looks as though all of those calls were made to my staff, not to me, and that the prisoner did not identify themselves as a serving prisoner, which I think underlines the fact that this is almost certainly due to inadvertence."
Meanwhile, Tory former prisons minister Crispin Blunt said that in reality the revelations were probably "not hugely important" if it could be confirmed that no action was taken as a result of the calls being monitored.
Mr Blunt said: "I think the key thing here is there appears to be no actions that then followed the number of cases of monitoring and that there was no strategy within the department to oversee MPs' conversations.
"And therefore perhaps in reality this is not a hugely important issue if it can be confirmed that no action was taken as a result of those calls being monitored in the normal way and now of course they won't be under the new system."
Mr Grayling said the monitoring was most likely down to a "series of errors".
He said: "I see no evidence that this was part of a particular attempt to gain individual pieces of information and to pass them on.
"In a very large and complicated system with a very large number of people, my first impression is that this was a result of a series of errors but that doesn't make it acceptable and of course I will be asking Nick Hardwick to confirm that it was a result of a series of errors but also to make sure it doesn't happen again."
Mr Straw urged the Justice Secretary to take into account a 2008 report which found the controversial taping of conversations Mr Khan had with a terror suspect in prison did not breach any rules.
The conversations between Babar Ahmad, an inmate of Woodhill Prison, and Mr Khan were taped but an inquiry by former judge Sir Christopher Rose found it was "inadvertent", Mr Straw said.
He asked Mr Grayling: "In 2008 following a disclosure in the Sunday Times that Mr Khan's conversation in a prison between him and a prisoner was being recorded, I set up an inquiry under Sir Christopher Rose, former very senior Court of Appeal judge, who also found that it was inadvertence and not conspiracy that led to this.
"May I suggest that that report of Sir Christopher Rose is drawn to the attention of Nick Hardwick for any lessons that could be followed through?"
Mr Grayling said he would pass the report to Mr Hardwick.
Prison Reform Trust director Juliet Lyon said: " This is not a breach of protocol - it is a fundamental breach of democratic rights and justice."
Mr Hughes said he was "angry" about the situation and insisted he would continue his work within government to uphold civil liberties.
He told BBC Radio 4's PM programme: "I am angry. I am also absolutely clear that we need to take action to prevent it happening, which is what has been done as quickly as humanly possible by the department responsible."
He added: "I'm very concerned that we continue to uphold civil liberties."