BUENOS AIRES — President Trump neared the end of an attenuated visit to the Group of 20 summit meeting here on Saturday, sitting down with the leaders of China and Germany, two countries he has threatened with trade wars over what he calls their unfair commercial practices.
“We have a tremendous trade imbalance, but we’re going to get that straightened out,” Mr. Trump said before a meeting with Chancellor Angela Merkel of Germany. “We all understand each other.”
Ms. Merkel said the two leaders would also discuss Ukraine, where a clash between Russian and Ukrainian ships last week caused tensions to flare between the two neighbors. It was cited by Mr. Trump as the reason he canceled a meeting with President Vladimir V. Putin at the meeting in Buenos Aires.
Later on Saturday, Mr. Trump began a dinner meeting with President Xi Jinping of China to discuss ways to avoid a new round of tariffs that some analysts fear could provoke a full-fledged economic Cold War between the world’s two largest economies.
“The relationship is very special, the relationship that I have with President Xi,” Mr. Trump told reporters, as he sat across a long table from the Chinese leader. “I think that is going to be a very primary reason why we’ll probably end up with getting something that will be good for China and good for the United States.”
Mr. Xi replied, “Only with cooperation between us can we serve the interest of world peace and prosperity.”
China is seeking to prevent Mr. Trump from following through on a plan to raise tariffs on $250 billion in Chinese goods to 25 percent, from 10 percent, on Jan. 1. In return, American officials said, the Chinese were likely to offer to increase their purchases of American soybeans and natural gas.
Neither a dramatic breakthrough nor an acrimonious breakdown was expected at the dinner. The most likely outcome, officials said, was an agreement to keep talking — a truce not unlike the one that Mr. Trump agreed to recently with the European Union.
Mr. Trump’s single-minded focus on trade with Germany has put Ms. Merkel in an awkward spot because Germany, as a member of the European Union, cannot negotiate separately on trade issues with the United States.
Still, Mr. Trump was a less disruptive presence at this meeting than he has been at other such gatherings. The members agreed on a 31-point communiqué that endorsed multilateral agreements like the Paris climate accord, while acknowledging the American insistence that it go its own way.
The statement also expressed concern about the World Trade Organization, a favorite target of Mr. Trump because he believes it crimps America’s ability to use tariffs and allows countries like China to cheat.
“The system is currently falling short of its objectives, and there is room for improvement,” the communiqué said, in a phrase that an administration official described as a victory for Mr. Trump.
The statement also did not include a reference to the dangers of protectionism, which American officials said could have held it up. Two weeks ago, a feud over language on trade between China and the United States stymied the drafting of a communiqué after an economic summit in Papua New Guinea — and it was never issued.
Mr. Trump said he canceled a news conference planned for Saturday afternoon out of deference to the family of President George Bush, who died a day earlier in Houston.
“The fact that we lost a president who truly was a wonderful person, a wonderful man, a great man — it really puts a damper on it, to be honest with you,” Mr. Trump said.
He turned to Ms. Merkel and asked her to share a recollection of a visit she made to the White House with then-Chancellor Helmut Kohl, when Mr. Bush was president. She referred to him as “one of the fathers of the German unification,” and said, “we will never forget that.”
Even before Mr. Bush’s death, the meeting was shadowed by Mr. Trump’s legal troubles back home — his former personal lawyer, Michael D. Cohen, pleaded guilty to lying to Congress about his dealings with Russia on behalf of Mr. Trump — and by his truncated schedule while in Buenos Aires.
This was the kind of diplomatic conclave at which Mr. Bush, a globe-trotting foreign-policy president, would have thrived. Mr. Trump’s less comfortable experience here attested to how the American role in the world has changed during the Trump presidency.
Mr. Trump also skipped a meeting with Crown Prince Mohammed bin Salman of Saudi Arabia, another strongman whom he has drawn close but who has fallen into disrepute. The C.I.A. has concluded the crown prince played a role in the killing of the Saudi dissident Jamal Khashoggi in the Saudi Consulate in Istanbul in October.
Mr. Trump’s stubborn defense of Prince Mohammed has caused tensions with Turkey, which has shared an audio recording of the attack on Mr. Khashoggi with American officials and demanded a fuller accounting from the Saudis of what happened.
On Saturday, Mr. Trump met with Turkey’s leader, Recep Tayyip Erdogan, but the White House closed the session to even the brief picture-taking opportunity that usually accompanies these meetings.
At a dinner for the leaders on Friday night, the White House said Mr. Trump spoke informally with Mr. Putin. There were photos of the president and first lady Melania Trump seated at the long table, separated from Mr. Putin by Mr. Xi and his wife, Peng Liyuan.