Barracks owner Project Blue Ltd had appealed against an earlier tribunal decision relating to its purchase of the Chelsea Barracks in London.
This appeal has now been rejected by the Upper Tribunal and Project Blue must pay £38m in stamp duty that would have been due if it hadn’t used the scheme.
The decision also affects 24 similar commercial cases and avoidance schemes with around 900 users, protecting another £85m in tax.
Project Blue – which is owned by the Qatari government – bought Chelsea Barracks in 2008 for nearly £1bn.
The site is now being converted into luxury flats.
David Gauke, Financial Secretary to the Treasury, said: “HMRC’s position in this important case has now been backed twice by the courts.
“The message is clear – tax avoidance is complex, expensive and self-defeating.”