Millgate Developments Ltd constructed nine two-storey houses and four bungalows on green belt land off Woodlands Park Avenue, Maidenhead, in 2014, having received planning permission for the project from the Royal Borough of Windsor and Maidenhead.
The 13 affordable housing units were part of much larger housing development on other land in the vicinity.
The covenants, which were contained in a 1972 land conveyance, benefited the owners of neighbouring land, including the Alexander Devine Children's Cancer Trust, which planned to build a hospice on its holding.
Before the homes were built, Millgate was aware that the land concerned was subject to restrictive covenants that forbade building of any structures on the site and restricted its use to open space for vehicle parking.
But Millgate decided to take the risk and it was only after the housing units were built that the company applied to the Upper Tribunal under section 84 of the Law of Property Act 1925 to set aside or modify the covenants.
In its 2016 decision, the tribunal characterised Millgate's conduct as "high-handed and opportunistic". However, despite objections from the charity, which said the wheelchair walk and gardens of the hospice would be overlooked, the tribunal modified the covenants so that the housing units would not have to be demolished.
Some of the new homes - which have since been sold to social housing provider Housing Solutions Ltd - were already tenanted and the impact on residents, were demolition to be required, weighed heavily with the tribunal.
It made modification of the covenants conditional on Millgate paying £150,000 compensation to the charity, that sum representing the cost of remedial planting and landscaping to screen the garden of the now completed hospice.
In ruling on the charity's challenge to the ruling, Lord Justice Sales noted that the tribunal had "found itself unable to say that Millgate had acted in good faith and without any intention to force the hand of the trust, or that Millgate had proceeded in ignorance of the objectors' right to enforce the restrictive covenants".
The judge, sitting with Lords Justice Underhill and Moylan, said the tribunal accepted that the developer had acted in deliberate breach of the restrictive covenants in order to try to force its hand to grant its application to modify the restrictive covenants "in view of the waste involved in potentially having to take down 13 units already built on the land".
Despite that, the court noted, the tribunal "held that the the public interest in preserving the units built in breach of covenant, as affordable housing, was so great as to justify the exercise of discretion in favour of Millgate".
In allowing the charity's appeal against the tribunal ruling, Lord Justice Sales emphasised the public interest in honouring contracts and ensuring that private property rights are upheld and protected.
He said: "A property developer which knows of a restrictive covenant which impedes its development of land has a fair opportunity before building either to negotiate a release of the covenant or to make an application to see if it can be modified or discharged. That is how the developer ought to proceed.
"It is contrary to the public interest in ensuring that proper respect is given to contractual or property rights for a property developer to proceed without any good excuse to build in violation of such rights, as contained in an enforceable restrictive covenant, in an attempt to improve its position on a subsequent application under section 84.
"It is contrary to the public interest for the usual protections for a person with the benefit of a restrictive covenant to be circumvented by a developer seeking to obtain an advantage for itself by presenting the tribunal with a fait accompli in terms of having constructed buildings on the affected land without following the proper procedure, and then in effect daring the tribunal to make a ruling which might have the result that those buildings have to be taken down."
The judge concluded: "In my view, in the circumstances of this case, in which Millgate had deliberately circumvented the proper procedures for testing and respecting the trust's right under the restrictive covenants, the tribunal could not properly be satisfied that it was contrary to the public interest for the restrictive covenants to be maintained in place.
"Millgate has acted in an unlawful and precipitate manner by building in breach of the restrictive covenants. It has acted with its eyes open and completely at its own risk. As a result, it is appropriate and in conformity with the public interest that it should bear the risk that it may have wasted its own resources in building the 13 housing units on the application land."
The Court of Appeal ruling means that the covenants remain in full force and, in order to save the housing units from demolition, Millgate will have to endeavour to negotiate a release from the trust. Although it no longer owns the site, Millgate had given an indemnity to Housing Solutions against any loss that might arise if the attempt to vacate or modify the covenants proved unsuccessful.
Earlier this week, the Court of Appeal upheld a Warwickshire council's enforcement notice against a landowner who removed two listed lead urns from the grounds of his home without permission, even though he no longer owns the urns and does not know where they are.
Also this week, a High Court judge overturned a decision by former communities secretary Sajid Javid to refuse plans for an opencast mine in Northumberland on grounds including the scheme's potential impact on climate change.
And last week, a High Court judge dismissed a claim that a planning inspector overstepped her powers in approving a developer's application to revise conditions imposed on a planning permission and increase the height of two wind turbines in west Wales by 25 per cent.