An election result which saw the wrong person elected as a councillor has been overturned by the High Court.
Highworth, in Wiltshire, has fewer than 7,000 registered voters but more than 40,000 ballots were counted after the town council election in May.
The error led to Tory candidate Pauline Webster being declared a winner instead of independent candidate Kim Barber and sparked a legal challenge and recount.
Mr Justice Knowles said the "miscount was recognised and corrected".
Highworth, near Swindon, had a voting population of 6,408 before the 2 May poll and only 2,477 ballot papers were issued.
But at the count, 41,939 votes were counted with each of the 10 Conservative candidates polling more than 3,000 votes.
A high court electoral petition was lodged by independent candidate Ken Smith, who argued block votes cast in favour of all the Conservative candidates had been counted for each of them, rather than split between them.
A recount was held resulting in thousands of votes being stripped from Tory candidates.
As a result Ms Webster, who received 727 votes, has had to make way for Ms Barber, who received 863 votes.
Swindon Borough Council admitted it made a mistake but said it was pleased the High Court had "ratified the recounted town council election results".
"It brings to an end what has been an unsettling time for candidates and councillors in Highworth," the council said.
"We have carried out a thorough lessons learned exercise in the wake of May's local elections to ensure this does not happen again."