A former magistrate who spent two years in jail before being cleared of rape has lost his legal battle to sue his accuser for £300,000 damages.

Anthony Hunt, 66, from Dorset, was jailed for four years in 2003, but had his conviction quashed on appeal in 2005. His initial attempt to sue his accuser for malicious prosecution failed last October after a high court judge ruled that the woman, known as AB, was not the prosecutor. Today the court of appeal upheld that decision, in a ruling which underlined the role of the crown as prosecutor in protecting key witnesses from damage claims. Women's rights groups greeted it with "a huge sigh of relief".

If Hunt's claim had succeeded it could have cleared the way for alleged victims of unwitnessed crimes to be personally sued for damages in cases where defendants were acquitted.

Anna Mills, a solicitor acting for AB, said yesterday that her client "feels vindicated by the decision". She said: "Before Lovells [law firm] agreed to assist AB with this case she had personally spent in excess of £60,000 defending Mr Hunt's claim. She has suffered more than 14 years of severe psychological and emotional trauma."