Finding himself all but ordered to praise Mr. Trump’s behavior with allies created an odd situation for a fellow world leader who had been invited to take part in only the second state visit of Mr. Trump’s administration. As a more damning picture of Mr. Trump’s conduct with Ukraine came into focus, both men made efforts to keep it from overshadowing the ceremony, capping off a day full of announcements of sanctions against Iran and a small troop deployment to the Middle East with a state dinner that resembled a cross between a Mar-a-Lago patio gathering and a black-tie political rally.

As the day went on, Mr. Morrison seemed to signal repeatedly that he was an ally just as happy to help as he was to stay out of Mr. Trump’s way.

“Mr. President, Australia may often look to the United States but we have never been a country that been prepared to leave it to the United States,” Mr. Morrison said to the president just after he arrived alongside his wife, Jenny. “We don’t. That’s not our way. We pull our weight.”

Mr. Morrison mirrored Mr. Trump’s “we’ll see what happens” stance on the idea of using further military force against Iran, and let Mr. Trump take the lead in his aggressive pursuit of a trade deal with China, a country the president called a “threat to the world” in a news conference on Friday. For his part, Mr. Morrison said he would like a deal to be reached in the name of global stability.

When it comes to managing the president’s mercurial instincts, some of his foreign allies have tried the bromance approach to get what they want. Others have tempted him with royal trappings, like the British did by invoking the actual queen of England. Twice. In his own state visit, Mr. Morrison’s pragmatic approach was a marked difference from the way Emmanuel Macron, the French president, participated in the Trump administration’s first state visit last year.