It was not a joke. A day earlier, Mr. Trump said on Twitter that Denmark was “a very special country with incredible people” but added that he was abandoning plans to visit because of the country’s refusal to sell Greenland, a semiautonomous part of the kingdom of Denmark.

Prime Minister Mette Frederiksen had said she had no interest in discussing the sale of Greenland. “Greenland is not Danish. Greenland belongs to Greenland,” Ms. Frederiksen told a Danish newspaper this week. “I strongly hope that this is not meant seriously.”

On Sunday, Mr. Trump said the idea of buying Greenland has been discussed in his administration because of the strategic benefits and in part because of its natural resources, like coal and uranium. He also suggested that the territory was a financial burden to Denmark.

“Essentially, it’s a large real estate deal,” Mr. Trump told reporters on Sunday of his interest in buying Greenland. “A lot of things can be done. It’s hurting Denmark very badly, because they’re losing almost $700 million a year carrying it. So they carry it at a great loss.”

Greenland’s government is in charge of most aspects of its affairs except foreign policy and defense. Local governments have not managed to develop a sustainable economy and receive more than 50 percent of the island’s budget in direct subsidies topped with additional Danish spending on defense and enforcement of sovereignty. The total bill amounts to $740 million annually.

On Wednesday, disbelief and condemnation echoed through the political landscape, as it began to sink in that Mr. Trump wasn’t kidding.

“Please stop,” Martin Lidegaard, head of the foreign affairs committee in Parliament, wrote on Twitter, before citing several other areas of discussion that he said should be of interest to both countries: the Arctic, climate change and the Middle East.

“Total chaos,” the former finance minister Kristian Jensen wrote. “This has gone from a great opportunity for a strengthened dialogue between allies to a diplomatic crisis.”

Before Mr. Trump canceled his visit, Ms. Frederiksen told a television reporter on Sunday in Nuuk, the capital of Greenland: “Thankfully, the time where you buy and sell other countries and populations is over. Let’s leave it there.” She also added, “Jokes aside, we would naturally love to have an even closer strategic relationship with the U.S.”

Loading...

But on Wednesday, Ms. Frederiksen acknowledged to reporters that the cancellation had been a surprise and “unusual,” and that she “regretted” it.

Adding to the already considerable awkwardness, Mr. Trump’s announcement that he was canceling his trip came not long after the American ambassador, Carla Sands, wrote on Twitter that Denmark was excited about the president’s visit.

A headline in Berlingske, a conservative daily, read “The U.S. and Denmark’s relationship has never been this ice-cold. It will have wide-ranging consequences.” A headline on the website of the state broadcaster read, “Trump sends Denmark and the U.S.’s relationship to the freezing point.”

Ms. Frederiksen, however, dismissed speculation that Danish-American relations had been damaged.

“I don’t believe the relationship is in crisis,” she said on Wednesday. “We are closely connected, and the United States is one of our most important allies. Our corporation will only expand in strength and range.”

She said that any upcoming decisions about Danish contributions to military missions in Syria or the Strait of Hormuz would be unaffected. She added that Mr. Trump was welcome to visit the country at another time.

“The American president and the American people are always welcome in Denmark,” she said.

Many Danes had seen Mr. Trump’s visit as a recognition of a special relationship with the United States built on decades of friendly relations, mutual interests in the Arctic, and Danish responsiveness to American calls to action.

Danish troops took part in American-led missions in Iraq, Syria and Afghanistan, where 43 Danish troops were killed, a staggering number for a nation of 5.5 million not used to war.

But the suggestion of a potential sale of Greenland by Denmark still stuck many as beyond the pale. “For no reason Trump assumes that (an autonomous) part of our country is for sale,” Rasmus Jarlov, a former minister of business, wrote on Twitter. “Then insultingly cancels visit that everybody was preparing for. Are parts of the U.S. for sale? Alaska? Please show more respect.”

Ole Spiermann, a former professor of international law and legal adviser to the government of Greenland, said that from the perspective of international law, “the Danish state has the sovereign right to sell or trade Greenland if it wishes.”

But Greenland’s right to self-determination under international law and also the Danish Constitution demand that “Greenland’s status cannot be changed without acceptance from the Greenlandic people.”

Any offer from Mr. Trump should be addressed to both Denmark and Greenland, Mr. Spiermann said. Should the people of Greenland want an association with the United States against the will of the Danish government, he added, they would first have to become independent from Denmark and then join the United States.

But perhaps suggesting he was enjoying the outrage over his interest in Greenland, Mr. Trump tweeted a photograph of a “TRUMP”-emblazoned gold skyscraper standing in the middle of a field and wrote, “I promise not to do this to Greenland!”

Pernille Skipper, the speaker of Parliament’s leftist red-green alliance, said on Twitter that Mr. Trump “lives on another planet. Smug and disrespectful.”

Noting that the president’s tweet said the visit had been postponed, rather than abandoned, Soren Espersen, who speaks for the populist Danish People’s Party on foreign affairs, suggested there was little point in Mr. Trump coming. “Why not just cancel?” he said. “We are so busy here with other things.”