The prime ministers of Denmark and Greenland welcomed the deal, which they said was yet to be signed

The US and Denmark have announced a deal on Greenland's security, resolving a diplomatic dispute sparked by President Donald Trump's threats to seize the territory by force.

Trump said the agreement would grant the US "permanent control over security, and all other needs" in the semi-autonomous Danish territory.

The leaders of Denmark and Greenland welcomed the deal to "strengthen security" in the region, which they said was expected to be signed next week, but did not outline its contents.

The announcement comes after months of threats by Trump to "take" Greenland over national security concerns, citing its strategic location for defence purposes and its mineral wealth.

No text of the agreement has been released. Trump said the deal came with "no cost to the United States" and would grant it the ability "to do what is necessary" to "secure and defend the security of Greenland", in a post on Truth Social.

He said it included a rule that no US adversary could maintain a military presence in Greenland or "make sensitive investments in Greenland, without our express written approval".

Denmark's Prime Minister Mette Frederiksen said she was "pleased that there is a prospect of a good agreement" for all three parties, which was expected to be signed at the UN General Assembly next week.

The deal "strengthens our common security in the Arctic and the North Atlantic area" while also recognising "the sovereignty and territorial integrity of the Kingdom and the right of the Greenlandic people to self-determination", she said in a joint statement with Greenland's Prime Minister Jens-Frederik Nielsen.

The agreement would still need to go through "the necessary parliamentary procedures to enter into force" once signed, the statement noted.

Nielsen said it was "gratifying that we are about to enter into an agreement that ensures and strengthens the security of Greenland, the Kingdom of Denmark, the United States and the Western alliance".

"The agreement recognises Greenland's interests and our place in international co-operation. It is for the benefit of us all," he said.

A Nato spokesperson said the military alliance welcomed the deal, which would "help advance security, stability and cooperation in this vital region".

US Secretary of State Marco Rubio called it a "historic deal" and a "huge win for the United States and the American people".

"This deal permanently and completely addresses our national security concerns in Greenland," he said in a statement.

Greenlanders protested against Trump's ambitions for the territory outside the American consulate in the country's capital, Nuuk, earlier this year

Trump had tried for months to purchase or annex the semi-autonomous territory, arguing that it was vulnerable to adversaries, including Russia and China.

His repeated demands to take Greenland earlier this year prompted an outcry from Greenlanders, Danes and other Nato members.

There is hope the crisis has now been brought to an end, with some Danish media interpreting the agreement as a quiet but significant triumph for the country's diplomacy.

"Don't tell Trump that it's the Kingdom of Denmark that has won," read one headline in the newspaper Berlingske on Saturday.

"Trump didn't get Greenland, but he was allowed to take a victory lap on social media," wrote a US correspondent for Politiken.

It is not yet clear what concessions or sweeteners, if any, have been agreed - and in Greenland, some are still nervous.

"[It's] news we have all been hoping for," MP Naaja Nathanielsen wrote on social media. But she added: "It is absolutely crucial that any agreement preserves our right to self-determination."

Former Greenlandic politician Aaja Chemnitz said she looked forward to the deal being finalised, but "until then, I'm sceptical".

"I don't have much confidence in Trump," she said.

Greenland's location between North America and the Arctic makes it well placed for early warning systems for missile attacks, and for monitoring vessels

The text of the agreement has not been published. The BBC has contacted the Danish Embassy in the US and the White House.

However, an unnamed US State Department official outlined the deal without providing specifics.

Among the agreed provisions is one stating the deal would not expire even if Greenland became an independent country in the future.

The official added that under the deal, the US has unilateral power to build additional military structures with no approval needed from Greenland or Denmark. It includes "permanent access, basing and overflights rights," the official said.

It also bans non-Nato countries from building bases in Greenland, and "bans adversaries from making investments in Greenland that could threaten the United States".

The official added that under the current status quo, adversaries have been allowed to invest in Greenland's "sensitive sectors without investment screening".

The official specifically referenced Russia and China, saying it blocks them from deploying troops or making investments in "sensitive sectors".

Without the official text being released, it is unclear how exactly the deal differs from a 1951 agreement with Denmark, under which the US can send as many troops as it wants to Greenland.

The US already has more than 100 military personnel permanently stationed at its Pituffik base in the north-western tip of the territory.

Trump says Greenland is essential for his plan to build a Golden Dome defence system, designed to protect the US against missile attacks from Russia and China, and that European allies could co-operate in this endeavour.

The island has vast - and largely untapped - reserves of rare earth minerals, many of which are crucial for technologies including mobile phones and electric vehicles.

Why does Trump want Greenland and what could it mean for Nato and the EU?

US in closely guarded talks to open new bases in Greenland

US allies won't forget Trump Greenland crisis