“Nambia’s health care system is increasingly self-sufficient,” Mr. Trump observed at a lunch on Wednesday for African leaders, kicking up a storm of derisory speculation on Twitter about whether he was conflating Namibia and Zambia or Gambia. (The White House later clarified that he meant Namibia.)
“Rocket Man is on a suicide mission,” he declared Tuesday, very deliberately from the rostrum of the General Assembly, about the North Korean dictator, Kim Jong-un. North Korea one-upped Mr. Trump on his reference to a 1970s Elton John lyric by labeling the president the “Madman Across the Water.”
As with his first overseas trip in May, the president started off on a deceptively mild and disciplined note, becoming looser, more outspoken and more sharp-elbowed as the week wore on.
In his first address to the other leaders, on Monday, he spoke approvingly about the enduring role of the United Nations and paid it what for him is the ultimate compliment: telling the audience that he deliberately built Trump World Tower opposite the slender green-glass and Vermont marble tower that houses the United Nations headquarters.
“I actually saw great potential right across the street, to be honest with you, and it was only for the reason that the United Nations was here that that turned out to be such a successful project,” Mr. Trump told the leaders, some of whom appeared puzzled that he viewed the 193-member world body — the successor to the League of Nations — as a real estate play.
Mr. Trump likes to break the ice with audiences by alluding to his business life. He did it again at the lunch with the African leaders. The president was dutifully extolling the continent’s investment potential when he suddenly looked up from his notes, spread his arms and smiled.
“I have so many friends going to your countries trying to get rich,” Mr. Trump declared. “I congratulate you. They’re spending a lot of money.”
Even on his first day, the president showed a disinclination to stick to his talking points. American and Israeli officials had briefed reporters exhaustively in the days before he was to meet Prime Minister Benjamin Netanyahu that the subject of the meeting was going to be the threat posed by Iran — not the quiescent Middle East peace process.
As he and Mr. Netanyahu took their chairs, however, Mr. Trump only wanted to talk about the peace process.
“It will be a fantastic achievement,” he said, as a poker-faced Mr. Netanyahu listened. “We are giving it an absolute go. I think there’s a good chance that it could happen. Most people would say there’s no chance whatsoever.”
Behind closed doors, administration officials insisted, Iran was still the primary subject of conversation. But whether out of comfort with talking about another deal or a simple desire to be unpredictable, Mr. Trump managed to reframe the meeting as being about an issue that neither the United States nor Israel had any intention to push at the General Assembly.
On Iran, too, Mr. Trump showed he liked keeping people guessing. Speaking to reporters on Wednesday, he said, “I have decided” what to do about the Iran nuclear agreement, which he has long derided as terrible. Then he would not tell them what the decision was.
Later, when Mr. Trump met with Prime Minister Theresa May of Britain, she asked him what his decision was. He would not tell her either. “Prime Minister May asked him if he would share it with her and he said no,” Secretary of State Rex W. Tillerson told reporters.
Mr. Tillerson, betraying the slightest hint of exasperation, added that he knew Mr. Trump had arrived at a decision but did not expect him to share that information with the public.
On his first foreign trip, Mr. Trump was mild-mannered in the Middle East and blunter in Europe. In New York, the polite president of Day 1 was replaced by a fire-breathing version on the second day, inveighing against Iran, Venezuela and North Korea. To some longtime American diplomats, Mr. Trump’s performance was offensive.
“When he declared to the world’s leaders that he was embarrassed by the Iran nuclear deal negotiated by his presidential predecessor, I felt he shamed America and thereby shamed himself,” said Martin S. Indyk, who served as ambassador to Israel under President Bill Clinton and as a Middle East envoy under President Barack Obama.
To some in the room, however, Mr. Trump’s emphasis on sovereignty and the sovereign rights of nations resonated.
“We believe in sovereign nations,” said Pakistan’s ambassador to the United Nations, Maleeha Lodhi. “We’d like to have the United States respect the sovereignty of other nations, just like he talked about.”
Mr. Trump also gleefully blurred the line between domestic politics and foreign policy. He began his major address by boasting about the performance of the stock market and the job market in the United States since his election. And he offered two extended monologues to reporters about prospects for the latest Republican effort to repeal the Affordable Care Act — one of them while seated next to the Egyptian president, Abdel Fattah el-Sisi.
These “pool sprays” are well-worn rituals at the General Assembly, opportunities for jostling reporters and camera people to get photographs and comments from national leaders before they meet. Normally, the leaders exchange handshakes and pleasantries, pretend not to hear troublesome questions and dismiss the news media pack as soon as they can without looking impolite.
But Mr. Trump did not miss a chance to score a point. Before President Moon Jae-in of South Korea met his American counterpart, Mr. Moon said, “North Korea has continued to make provocations, and this is extremely deplorable, and this has angered both me and our people.”
Grinning, Mr. Trump did not miss a beat. “I am very happy you used the word deplorable,” he said to the South Korean leader. “I was very interested in that.” Turning to the news media, Mr. Trump said, “I promise I did not tell him to use” that word, adding, “That is a very lucky word for me, and many millions of people.”
Hillary Clinton, it goes without saying, is not among them.