London's high court heard a storm broke out almost immediately after Conservative candidate Valerie White was declared the winner in a by-election for the Pakenham ward of St Edmondsbury BC on September 4 this year.
She was officially recorded as polling 196 votes and her rival Liberal Democrat Lisa Couper was recorded as having 102 votes.
But a blunder by one of returning officer Lynn Aisbett's administration staff meant that 100 votes had not been recorded and in reality Mrs Couper had won by six votes.
But on Friday judges Lord Justice Brooke and Mr Justice Gage, after an application from Mrs Couper, agreed she should be declared councillor for Pakenham without the need for a by-election.
Making the declaration and ordering Mrs Aisbett should pay all the legal costs for Mrs Couper and Mrs White as well as her own legal costs, Lord Justice Brooke told the court how the administration officer Mrs Rhodes Ogden had discovered her mistake almost immediately after the election.
While she and other staff were tidying up the village hall where the count had been held she began to suspect she had wrongly recorded the number of votes cast.
The ballot papers, in accordance with election laws, had by then been sealed up but Mrs Rhodes Ogden took the envelope home and in the presence of her husband and another member of the administration staff, opened it and recounted the votes on her kitchen table.
As soon as she discovered the truth she telephoned Mrs Aisbitt and told her what had happened and the horrified Mrs Aisbett contacted Mrs White and Mrs Couper.
The following morning at a meeting in Mrs Aisbett's office the votes were again recounted in the presence of the two candidates, again revealing Mrs Couper had won.
On Friday after counsel for Mrs Couper, Helen Mountfield, applied for a declaration her client be declared the winner, Mrs White's counsel, Richard Price QC, while not opposing the application, told the court the two unofficial recounts had been in 'clear breach' of the laws governing elections.
While he accepted the recounts had had no effect on the true result and there was 'no tampering' with the votes he said the court should not condone them and it should be made clear sealed ballot papers could not be re-opened without a court order.
And giving judgment Lord Justice Brooke agreed.
He said: 'It is desirable that the greatest possible publicity be given to the importance of this rule which is designed to ensure the complete secrecy of the ballot box and to ensure the votes people cast in elections are kept completely secure.
'I accept Mr Price's submission breaches of the rules of this nature should not be condoned by this court. It is crucial to the integrity of an election that ballot papers should be sealed once they have been counted.'
But he added: 'The breaches in this case made no difference to the result.'
After giving judgement both judges agreed Mrs Aisbett should pay all the legal costs, a ruling accepted by her counsel, Gavin Millar.
He told the court Mrs Aisbett had apologised to both Mrs White and Mrs Couper as soon as she discovered what had happened and she now apologised again to the court.