Former Lord Chancellor Lord Falconer was "too slow" to defend a judge after government criticism of his sentencing of a Cardiff paedophile, peers say.
The Lords constitution committee said he had failed in his duty in 2006 when then Home Secretary John Reid attacked the sentencing of Craig Sweeney.
Sweeney, who abducted a girl of three, was jailed for 18 years but told he may be eligible for parole in five years.
Peers warned that ministers' attacks on judges threatened their independence.
Mr Reid condemned the sentencing of Sweeney, who abducted the girl in Cardiff and sexually abused her in his Newport flat, as "unduly lenient" and asked Attorney General Lord Goldsmith to review it.
Lord Goldsmith later concluded it had not been "unduly lenient".
In a report entitled Relations Between the Executive, the Judiciary and Parliament, peers said the sentencing row had been "the first big test" of the relationship between judges and the lord chancellor since the Constitutional Reform Act 2005.
But there had been a "systemic failure", it found.
Committee chairman Lord Holme said: "The independence of the judiciary needs to be protected from populist politicians pandering to the prejudices of tabloid editors.
"The lord chancellor has a statutory duty to protect judges from inappropriate political criticism and to reprimand ministers who indulge in it.
"It is clear that in the Sweeney case, Lord Falconer failed in that duty and allowed the comments from the home secretary to go unchallenged for too long."
The committee recommended that the Ministerial Code be revised to include "strongly worded guidelines" on public comments by ministers on individual judges.
The media, particularly the tabloid press, was also criticised and was asked to restrain from attacking judges.
Judges were seen as "fair game" despite the fact that they cannot and should not publicly defend themselves in such situations, peers said.
Peers said the Press Complaints Commission's code of practice should encourage restraint and judges could make better use of press releases to explain their decisions - but should never have to justify them.
The constitution committee also looked at the creation of the Ministry of Justice when Mr Reid split the Home Office in May.
It said it had "significant constitutional implications" but that ministers had tried to dismiss it as simply a machinery of government change.
The government was criticised for "failing satisfactorily to consult the judiciary on the proposed changes".
A joint working group had been set up 10 days before it was announced that the Ministry of Justice was to be created.
Lord Holme said: "The government must learn to treat the judiciary as a constitutional partner, not merely the subject of change".
A separate Commons constitutional affairs committee report said there should have been proper debate.
When the ministry was announced, senior judges feared their independence would be compromised as the lord chancellor takes responsibility for prisons and probation as well as courts.
Committee chairman Alan Beith said: "We have been left with a highly regrettable conflict between our senior judges and the minister who is statutory guardian of their independence, which could and should have been avoided.
"[Justice minister] Jack Straw needs to get to grips with this issue quickly."