Professor Sir Roy Meadow today won his appeal against being struck off the medical register for giving misleading testimony that led to a mother being wrongfully jailed for the murder of her two baby sons.
A high court judge also overturned the General Medical Council's ruling that the senior paediatrician had been guilty of serious professional misconduct for providing "erroneous" evidence that helped convict Sally Clark of murdering her two sons.
The verdict against Ms Clark was later quashed.
Mr Justice Collins, sitting in London, said any witness giving evidence in a court of law was protected from civil prosecution or disciplinary action.
The judge said Sir Roy's actions in Ms Clark's 1999 trial could not properly be regarded as serious professional misconduct because "he had acted in good faith".
"It is difficult to think that the giving of honest, albeit mistaken, evidence could - save in an exceptional case - properly lead to such a finding," he said.
He added he had "no doubt" that the complaint against Prof Meadow should not have been pursued. "Since it was based upon his evidence in court, he had immunity," he said.
Prof Meadow, who was out of the country today, said he was relieved by the high court's verdict.
"This is an important decision for paediatricians and all doctors, nurses, teachers and other professionals who may have to express difficult and sometimes unpopular opinions in the course of giving evidence in court," he said.
"They should be able to do so without the fear of prosecution by the General Medical Council or other professional regulators."
However, the GMC warned the ruling would place doctors acting as expert witnesses in court cases beyond the reach its scrutiny.
"This would be true even when they, or their evidence, have been criticised by the court," a GMC spokeswoman said. "The only exceptions would be if the judge complained to the regulator."
Prof Meadow appealed against the GMC decision and punishment after being condemned for giving evidence outside his professional expertise in Ms Clark's criminal trial.
His evidence said there was only a one in 73m chance of two infants dying from sudden infant death syndrome in a household such as hers.
However, it later emerged that this evidence was wrong, taking no account of genetic or environmental factors and 25 years of research showing the odds of two cot deaths in one family were only one in 77.
The GMC's fitness to practise panel concluded that the professor had "abused his position as a doctor" and "seriously undermined" the position of all doctors giving evidence in trials.
But the judge said he had made only one mistake in his evidence - misunderstanding and misinterpreting the statistics.
"It was a mistake, as the [GMC] accepted, that was easily and widely made," he said. "It may be proper to have criticised him for not disclosing his lack of expertise, but that does not justify a finding of serious professional misconduct."
The judge added that the GMC's decision had been damaging because it had increased the reluctance of medical professionals to give evidence in child abuse court cases.
His view was backed by the Royal College of Paediatrics and Child Health, which welcomed the high court ruling.
"If the original [GMC] decision had stood, there is a real danger that doctors across all specialities would have become reluctant to undertake vital expert witness work," a spokeswoman said.
Prof Meadow, of Leeds, also gave evidence in two other high-profile child murder trials in which mothers were wrongfully convicted. Angela Cannings and Donna Anthony were jailed for murdering their children, but were later cleared by the court of appeal.
Ms Cannings said today she was "very disappointed and disheartened " by the high court ruling, given that the GMC ruled Prof Meadows had given evidence in an area - child death statistics - beyond his professional expertise.
"On a personal level it's very hard for us to accept when expert witnesses do make mistakes in the courtroom and you have a knock-on devastation effect on families involved," she told the BBC.
"If an expert witness gives evidence in their field of expertise, they should have no reluctance at all to go into a courtroom.
"It's when they are approached about areas outside their expertise then they should look up and say: 'Sorry, I can't deal with this', and actually step back."