* Judge dismisses activists' challenge to Goldman deal
* Says taxman made mistakes but did not break law
* Ruling adds to debate on corporate tax avoidance
By Estelle Shirbon
LONDON, May 16 (Reuters) - Britain's tax authority was heavily criticised by a judge on Thursday, who nonetheless ruled its deal with Goldman Sachs worth up to 20 million pounds ($30 million) to the U.S. bank was lawful.
High Court Judge Andrew Nicol dismissed a claim by campaign group UK Uncut Legal Action that the tax settlement with the bank in 2010 was an unlawful "sweetheart deal".
But he criticised the way HMRC had decided how much tax Goldman Sachs should pay.
"The settlement with Goldman Sachs was not a glorious episode in the history of the Revenue," the judge wrote, before listing errors made by HMRC.
"However, my task is to decide whether the decisions of HMRC under challenge were unlawful," he wrote, citing a previous ruling that said "maladministration and illegality are separate issues".
The judgment feeds into the debate on corporate tax avoidance in Britain, where some lawmakers have accused the taxman of being "too cosy" with big business.
At a time of government austerity cuts and economic stagnation, the question of how big companies keep their tax bills low is considered a matter of high public interest.
Google Inc was facing another grilling over its tax affairs on Thursday from a committee of lawmakers who called the company back after questions were raised about testimony given in an earlier hearing.
A Reuters investigation has revealed that the tax take from big companies fell sharply in the past 12 years, despite profits rising, while income taxes from individuals and small businesses have risen.
HMRC said the judge's ruling had "drawn a line under the Goldman Sachs issue".
"The High Court's comprehensive dismissal of UK Uncut's claim puts to rest the fallacy that HMRC is soft on large businesses," Director General for Business Tax Jim Harra said.
The case was heard earlier this month.
UK Uncut Legal Action said it was disappointed by the ruling, but the court case had helped expose what went on behind closed doors between HMRC and large companies.
Goldman Sachs, which was not a party to the court case, declined to comment.
The case concerned a deal reached orally in November 2010 between then HMRC boss Dave Hartnett and Goldman Sachs executives to resolve a long-running dispute over a now-banned tax avoidance scheme involving the payment of bonuses to UK staff via an offshore tax haven.
UK Uncut alleged that Hartnett had wrongly agreed that Goldman should pay the principal it owed but not the interest that had accrued during the five-year dispute.
Hartnett then approved the deal despite opposition from HMRC's own High Risk Corporate Programme Board, partly to avoid embarrassing George Osborne, the finance minister.
Osborne had just announced a new tax code for banks aimed at reducing avoidance and Goldman was threatening to pull out of the code if Hartnett reneged on the oral settlement.
"Mr Hartnett took into account the potential embarrassment to (Osborne) if Goldman Sachs were to withdraw from the tax code. HMRC accepts that was an irrelevant consideration and should not have featured in his decision-making process," the judge wrote.