The UK Independence Party stands to forfeit nearly £350,000 in donations after the Court of Appeal ruled today in favour of watchdog body the Electoral Commission.
A long-running legal dispute between the Commission and the party centred on donations in the form of cash and services from retired bookmaker Alan Bown at a time when he was not on the electoral roll.
Three judges ordered the case back to the magistrates' court for a new decision on forfeiture based on their findings.
Sir Paul Kennedy said: "In the present case I can detect nothing which would entitle the magistrates' court not to make the forfeiture order which the EC seeks."
Mr Bown had been on the electoral register in Thanet, Kent, but was removed by mistake without his knowledge in December 2004.
He did not find out until December 2005 and he was reinstated the following February.
Ukip, which has one MP and 10 MEPs, admitted breaking the law, but said it was due to a clerical error and that to order forfeiture of the entire sum would be disproportionate.
In August 2007, City of Westminster Magistrates' Court held that although Ukip had not taken "all reasonable steps" to establish that Mr Bown was on the roll, the error was accidental.
It ruled that Ukip should forfeit only £18,481 of the total but the Commission brought a judicial review of the decision and the High Court ordered a fresh hearing.
That was put on hold when the watchdog referred the case to the Court of Appeal to clarify aspects of the law.
Sir Paul said the law requires a political party to take "all reasonable steps" to verify that a donation is permitted.
One of the rules is that donors must be on the electoral register if they give more than £200. This was enacted primarily to stop foreign donations.
"Parliament having decided that the test of acceptability of a donation from an individual should be whether that individual was registered in an electoral register, it seems to me to be irrelevant whether an impermissible donor is or is not making a foreign donation," said Sir Paul.
He said magistrates' courts should "not be seduced" into ignoring the wording of the Act governing donations.
"The fact that Ukip accepted donations from Mr Bown without realising that he was no longer in an electoral register is also, to my mind, immaterial."
Welcoming the decision, the Electoral Commission said: "The effect of the Court of Appeal's judgment is that, in all but exceptional circumstances, political parties should give up in full donations accepted from an individual who is not a 'permissible donor'."
Peter Wardle, chief executive, commented: "We brought this appeal because the magistrate's court decision created some uncertainty for political parties about the way the law should be applied. In this case, a party had accepted money that it should not have, but was allowed to keep most of it.
"Political parties need to raise money to campaign, develop policy and communicate with voters. But all parties also need to follow the rules. And these rules need to be clear, simple and easy to follow.
"Parliament decided that political parties should only be able to accept money from individuals if they are on a UK electoral register. This provides a straightforward test of whether they should accept money or not. They simply need to check the electoral register. The United Kingdom Independence Party did not take these simple steps.
"The court agreed that we took the right approach in this case, an approach that was in line with the intentions of Parliament when passing this legislation."
In February 2007 the commission sought forfeiture of 67 donations totalling £367,697 after a district judge ordered that Ukip should forfeit just £14,481.Reuse content