A dispute flared over the Balfour Beatty built Stepps primary school and community centre, near Glasgow.
This was completed back in 2007, but in 2015 serious problems with the drainage system emerged and last year a drain collapsed.
Last September an adjudicator ruled that Balfour Beatty was liable to pay £4m in damages, but Balfour challenged the legality of the decision because of the use of “without prejudice” documents to inform the ruling.
Judge Lord Ericht has now upheld the adjudicator’s decision, giving Balfour until Tuesday to pay the cash.
Stepps primary school and nursery class will close for one year from July 2020 to allow essential repair work to take place.
This will allow extensive remedial works to the drainage system beneath the building including excavating trenches to carry out the work.