The UK government has defended a deal to give the Chagos Islands to Mauritius and lease back a key military base, following criticism from US President Donald Trump over its handling.

In a post on social media, Trump labelled the move as an act of great stupidity, months after he and senior US officials endorsed it. Later on Tuesday he confirmed he was against the deal.

The UK government said it would never compromise on our national security, while the prime minister's official spokesperson insisted the US still supported the move.

The UK signed the £3.4bn ($4.6bn) agreement in May, under which it would retain control of a UK-US military base on the largest of the islands, Diego Garcia.

In a post on his Truth Social platform that morning, Trump had said: Shockingly, our 'brilliant' NATO Ally, the United Kingdom, is currently planning to give away the Island of Diego Garcia, the site of a vital U.S. Military Base, to Mauritius, and to do so FOR NO REASON WHATSOEVER.

There is no doubt that China and Russia have noticed this act of total weakness.

He added: The UK giving away extremely important land is an act of GREAT STUPIDITY, and is another in a very long line of National Security reasons why Greenland has to be acquired.

Responding, the prime minister's official spokesman said that the US supports the deal and the president explicitly recognised its strength last year.

He added that it was also backed by the UK's Five Eyes allies, the other members of which - besides the UK and US - are Canada, Australia, and New Zealand.

They added that the agreement had secured the operations of the joint US-UK military base for generations, with robust provisions for keeping its unique capabilities intact and our adversaries out, and noted the deal had been welcomed by allies including the US.

The agreement followed a long-running dispute between the UK and Mauritius - a former British colony - about sovereignty over the Chagos Islands. The Chagos Islands were separated from Mauritius in 1965 when Mauritius was still under British rule. Britain purchased the islands for £3m, but Mauritius has argued that it was illegally forced to give them away as part of a deal to gain independence.

Under the deal agreed in May last year, the UK would hand over sovereignty of the islands to Mauritius while retaining control of the military base on Diego Garcia. It would lease back Diego Garcia for a period of 99 years - at an average cost of £101m a year.

Before signing the deal, the UK offered Trump an effective veto, because of its implications for US security. Allies of the president had criticised the plan, but during a meeting with Sir Keir in the Oval Office last February, Trump said I think we'll be inclined to go along with your country.

On Tuesday, Conservative leader Kemi Badenoch said in a post on X that the prime minister now had the chance to change course on Chagos. She said that paying to surrender the Chagos Islands is not just an act of stupidity, but of complete self-sabotage.

Two British Chagossian women born on Diego Garcia - Bernadette Dugasse and Bertrice Pompe - want the right to return to their place of birth and say they were excluded from discussions over the deal. Pompe stated she views the US president's criticism of the deal as a good thing but only words. Dugasse expressed hope that the deal will be halted altogether.