LONDON — He quoted Roosevelt and gently greeted frail veterans at a D-Day commemoration, hours after proclaiming Bette Midler a “psycho” and Chuck Schumer a “creep.” He exalted soldiers’ bravery while dismissing his avoidance of service in Vietnam, calling it a country “nobody heard of.” He toasted Britain’s queen at a Buckingham Palace banquet, after calling London’s mayor a loser.

For President Trump, reconciling his impulses with the expectations for an American president has often posed a hurdle. And when he had idle time during his three-day trip to Britain, the gap between the two — which has come to define his presidency — was jarring.

Mr. Trump’s trip to Britain ended Wednesday much as it had begun: as a split screen of a president embracing regal respectability on one side and settling scores on the other.

His host for the state visit was the royal family. With the exception of encouraging one state dinner guest to say nice things about him on television as Queen Elizabeth II stood nearby, Mr. Trump was well-behaved and well-received, according to British officials who had been concerned about possible missteps.

Yet from Monday to Wednesday, Mr. Trump used more familiar milieus — Twitter and friendly interviews — to attack critics and commandeer attention.

In an interview broadcast Wednesday, Mr. Trump told a British television host that he was “never a fan” of the Vietnam War and was making up for having avoided the draft by becoming America’s commander in chief.

A few hours later, Mr. Trump read from the address his World War II-era predecessor, Franklin D. Roosevelt, delivered to the nation on the evening of D-Day, the Allied invasion of Europe on June 6, 1944.

Mr. Trump’s shifting persona was reflected in policy issues as well.

The president arrived in Europe embracing a number of positions that are anathema to many of the people he encountered. But he pivoted abruptly when he found resistance, underscoring that his approach is less ideological than transactional and situational, and sowing confusion about what, exactly, is Mr. Trump’s bottom line.

Image

Mr. Trump and the first lady, Melania Trump, with Prince Charles and Camilla, Duchess of Cornwall, at Winfield House in London on Tuesday.CreditDoug Mills/The New York Times

He insisted that Britain’s public health system needed to be part of any trade negotiation with the United States, but then swiftly took it off the table. He likened the idea of a hard border between Northern Ireland and the Irish Republic, after Brexit, to his border wall with Mexico, but then agreed with Ireland’s leader, Leo Varadkar, that there should be no wall dividing north and south.

At heart, Mr. Trump’s instincts are contrary to the multilateral spirit of the European Union. But his salesman’s desire to please made him curiously solicitous of leaders whose views he might otherwise condemn.

When Mr. Trump spoke on Wednesday at an event in Portsmouth, England, honoring the 75th anniversary of the invasion, he was a solemn head of state standing with traditional allies. He used soft, respectful tones to greet veterans of the war that saved Europe from the Nazis.

Only hours earlier, as most of London slept, the other Mr. Trump was awake at the United States ambassador’s residence, tweeting that Ms. Midler, the singer, was a “washed up psycho” and that Mr. Schumer, the Democratic Senate minority leader, was a “creep.”

(It was not lost on some Portsmouth spectators that Mr. Trump’s remarks there were followed by a performance of the iconic World War II song, “Boogie Woogie Bugle Boy,” one of Ms. Midler’s biggest retro hits.)

Mr. Trump also falsely claimed on Twitter that the crowds of people who came out to greet him in London were all supporters — when, in fact, there were also many protesters. At a news conference with Prime Minister Theresa May on Tuesday, the president, who is often unsettled by protesters, dismissed the demonstrations as “fake news.”

His comments about Vietnam came in an exchange with Piers Morgan, the British television personality, former tabloid editor and a winner of the “Celebrity Apprentice,” the offshoot of Mr. Trump’s reality television show — and someone the president considers a friend.

Against the backdrop of the D-Day commemorations honoring the bravery of troops, Mr. Morgan, host of “Good Morning Britain,” asked him about his military deferments during the Vietnam War for a claim of bone spurs in his heel.

Image

Piers Morgan with Mr. Trump and his daughter Ivanka in 2014, during an “Apprentice” season.CreditDouglas Gorenstein/NBC

Mr. Trump said he had never supported the war in Vietnam and insisted that back then, “nobody had ever heard of the country,” drawing a contrast with Nazi Germany.

When asked if he would have served in Vietnam if not for the bone spurs, Mr. Trump said, “I would not have minded that at all; I would have been honored.”

“I think I make up for it now,” he said.

Mr. Trump appeared most presidential in his appearance at Portsmouth, on the coast of southern England, one of the key embarkation points for the D-Day invasion of Normandy, France.

The president spoke for less than two minutes, reading an excerpt from a prayer that Roosevelt delivered in a radio address on the evening of the invasion.

“Almighty God,” he read, “our sons, pride of our nation, this day have set upon a mighty endeavor, a struggle to preserve our republic, our religion, and our civilization, and to set free a suffering humanity. They will need thy blessings. For the enemy is strong.”

Mr. Trump’s three-day trip punctuated the vagaries of his stands on some issues. He reiterated the possibility of armed conflict with Iran, but expressed his previously stated desire to talk with Iranian leaders. And he muddied his well-known denial of climate change and the science behind it.

The climate issue came up in a meeting with Prince Charles, which Mr. Trump said had turned into a 90-minute discussion. “He is really into climate change, and I think that’s great, I mean I want that, I like that,” Mr. Trump said in the interview with Mr. Morgan.

Image

Prince Harry, right, with Ivanka Trump at Buckingham Palace on Monday.CreditDoug Mills/The New York Times

When Mr. Morgan pressed him on whether he believes in it, he said, “I believe that there’s a change in weather, and I think it changes both ways.”

Mr. Trump also seemed impressed with what he described as the prince’s forward-looking thinking. “I’ll tell you what moved me is his passion for future generations,” he told Mr. Morgan. “He’s really not doing this for him.”

But Mr. Trump said he had dismissed the suggestion that the United States should do more. “Well, the United States right now has among the cleanest climates,” he said, adding incorrectly that pollution has lessened during his presidency.

In the interview, he also cast his ban on transgender people serving in the military as an economic decision — an assertion at odds with what administration officials defending the ban have said. Mr. Trump also admitted having used the word “nasty” in connection with Meghan, Duchess of Sussex, Prince Harry’s wife.

Mr. Trump had set the stage for his second trip to Britain as president with other interviews, in The Sun and The Sunday Times, which are owned by Rupert Murdoch. Asked by The Sun’s reporter about criticisms that the Duchess of Sussex had made about him in 2016, when she was Meghan Markle, an American actress, Mr. Trump said, “I didn’t know she was nasty.” He later denied saying “nasty,” although it had been recorded.

On Wednesday, Mr. Trump acknowledged to Mr. Morgan he had said the word but sought to clarify the context: “I wasn’t referring to she’s nasty. I said she was nasty about me. And, essentially, I didn’t know she was nasty about me.”

Mr. Morgan was at his most adversarial when he asked why Mr. Trump claimed to support rights for lesbians, gay men, bisexuals and transgender people, but was enforcing a ban on transgender military recruits.

Mr. Trump, who in his 2016 campaign included transgender people among those whose rights he would support, repeatedly cast the ban as an economic decision. Mr. Trump suggested that transgender people were enlisting as a way to cover medical costs. He also suggested, falsely, that they cannot use prescription drugs in the military. Drug abuse is prohibited, but not prescriptions.

“They take massive amounts of drugs,” he said. “They have to.”

When Mr. Morgan interjected that the American military spends more money on Viagra for servicemen than on transgender medical bills, Mr. Trump was unfazed.

“Well, it is what it is,” he said. “Look, massive amounts — and also people going in and asking for the operation — you know the operation is $200,000, $250,000 — and getting the operation. The recovery period is long and they have to take large amounts of drugs after that for whatever reason, but large amounts, and that’s not the way it is. I mean, you can’t do that.”

A version of this article appears in print on , Section A, Page 1 of the New York edition with the headline: Split-Screen View of Trump Trip: Respectability vs. Score-Settling. Order Reprints | Today’s Paper | Subscribe