The Grade II* listed Tone Mill, near Taunton, is a derelict heritage asset in need of restoration.
It has been owned by Wet Finishing Works Limited since 2005 and the possibility of raising funds via the residential development of surrounding land has long been mooted.
A connected company, Mendip Estates Limited, began buying up land in the area, but its initial hopes of building 130 new homes were shelved due to flood risk.
But in 2012, housebuilders, Strongvox Homes, were granted planning consent for an 84-unit development by Taunton Deane Borough Council.
The project was viewed as the most feasible means of securing the mill's restoration and permission was granted subject to a section 106 agreement.
It was agreed that Strongvox would pay a £780,000 Heritage Asset Contribution (HAC) to the council, who would in turn would pay it to Wet Finishing for use in the mill's restoration.
Certain preparatory works had been carried out on the site, but Mr Justice Singh said there was a dispute - which he was not required to resolve - as to whether the planning consent had been implemented and the duty to pay the money triggered.
Matters moved on in November 2016 when the council granted Strongvox an amended planning consent, increasing the number of permitted residential units from 84 to 90.
At the same time, the council entered into a new section 106 agreement with Strongvox - although, this time, Wet Finishing was excluded from the negotiations.
Strongvox agreed to pay a £780,000 contribution to the council for its own use in the mill's restoration.
Wet Finishing, who had been served with notice to repair the mill a year earlier, were cut out of the process, the court heard.
In ruling on Wet Finishing's judicial review challenge, Mr Justice Singh rejected arguments that the council had acted beyond its powers.
But, in overturning the 2016 consent, he noted that the council had given Wet Finishing no opportunity to see the new section 106 agreement, or comment on it in draft, prior to the decision to grant permission. The council had thus failed in its duty to act fairly.
Jack Parker of Cornerstone Barristers, who acted for the successful claimant, said: "The decision provides a useful reminder and guide for local authorities about the extent to which they may be under a duty to consult on the terms of a section 106 agreement, particularly where the terms of any existing agreement are being varied to the detriment of one of the parties.
"The court’s finding that the conditions attached to a planning permission may be varied to permit a developer to build a greater number of dwellings than were granted permission originally may be surprising for some but in any event demonstrates the flexibility of the section 73 process."
R on the Application of Wet Finishing Works Limited v Taunton Deane Borough Council. Case Number: CO/6473/2016