The European Medicines Agency must comply with the terms of the lease on its London headquarters despite the UK’s exit from the EU, a judge ruled on Wednesday in a closely followed case.

The judge, Marcus Smith, said: “I conclude that the lease will not be frustrated on the withdrawal of the UK from the EU . . . the EU remains obliged to perform its obligations under the lease.”

The outcome represents a victory for Canary Wharf Group, the agency’s London landlord, and a blow to the European regulator, which is in the process of relocating to Amsterdam in order to stay within the EU after Brexit.

The EU agency had sought to escape lease obligations worth about £500 million related to the London headquarters in 25-30 Churchill Place, which is leased until 2039.

Canary Wharf Group, the developer of the London Docklands financial district, lodged the High Court case asking the court to enforce the contract after the agency argued it would no longer be valid after the UK’s exit from the European bloc.

The EU’s medicines regulator had argued Brexit would “frustrate” the lease - an English legal term meaning an unexpected event has made a contract impossible to fulfil, or has drastically changed the original reason for signing it.