President Trump on Wednesday said that the new prime minister of Denmark was “nasty” to him when she rejected his interest in purchasing Greenland, as he explained why he abruptly canceled a trip to the European nation next month.

Mr. Trump made the remarks to reporters outside the White House as he departed for a trip to Kentucky for an official event.

The statement from Mette Frederiksen, the 41-year-old prime minister of Denmark, had called Mr. Trump’s hope of buying Greenland “absurd,” a statement the president called “nasty.”

“I thought it was a very not nice way of saying something,” Mr. Trump told reporters. “But all they had to do is say, no, we’d rather not do that or we’d rather not talk about it.”

Mr. Trump asserted he was taking umbrage on behalf of his nation.

“She’s not talking to me, she’s talking to the United States of America,” he said. “They can’t say ‘how absurd.’ ”

Mr. Trump was said to have been bothered by the mockery he received from officials in Denmark and elsewhere over the news, first reported by The Wall Street Journal, that he had instructed his advisers to explore whether it was possible to take over possession of Greenland. Mr. Trump is interested in it for strategic military purposes, as well as because of its natural resources.

But aides had said privately that he was already losing interest in the trip before the remarks from Denmark’s prime minister.