President Barack Obama and Russian President Vladimir Putin spoke face-to-face for what could be the last time on Sunday on the sidelines of an economic summit underway in Peru.

The world leaders have spent much of Mr. Obama’s presidency at odds over a host of issues, and Putin spent the 2016 presidential campaign cheering for Obama’s political rival, Donald Trump, who will take the Oval Office on January 20.

Presidents Obama and Putin were seen chatting as reporters were allowed in briefly for the start of the opening session of the Asia-Pacific Economic Cooperation summit in Lima. They stood off to the side together momentarily before shaking hands and then taking their seats around a table.

Get Breaking News Delivered to Your Inbox

Although their words weren’t audible to journalists present, the White House said the conversation lasted four minutes and mostly focused on Syria.

A White House official alter said Mr. Obama encouraged Mr. Putin to uphold his country’s commitments under the Minsk deal aimed at ending the Ukraine conflict. The White House said Obama also called for U.S. Secretary of State John Kerry and Russian Foreign minister Sergei Lavrov to keep working in initiatives with other countries to lower violence in the Syria crisis and alleviate suffering.

At the G-20 summit in China earlier this fall, Mr. Obama and Mr. Putin met to negotiate a ceasefire in Syria but weren’t able to reach an agreement, with Mr. Obama saying “gaps in trust” between the U.S. and Russia were hindering discussions.

Mr. Obama and Mr. Putin have long had a strained relationship. President-elect Trump’s election has raised speculation and concern he might do less to challenge Russian aggression. Trump has spoken warmly about Putin, and vice versa.

The American and Russian leaders aren’t expected to have any formal meetings while both are in Peru.

Trying to tie up loose ends of his foreign policy agenda, Mr. Obama on Saturday instead found world leaders more focused on someone else: Mr. Trump’s election.

Global hand-wringing over America’s next president has taken much of the wind out of President Obama’s final overseas trip. Adopting an altruistic tone, Mr. Obama has offered frequent reassurances that the U.S. won’t renege on its commitments. Yet he’s been at a loss to quell concerns fully, given new signals from Trump that he intends to govern much the way he campaigned.

Mr. Obama’s visit to Peru, the last stop on his trip, has brought those concerns to the forefront: Much of Latin America is on edge about a potentially dramatic shift in U.S. immigration policy under Mr. Trump. And Asian leaders gathered in Lima for an Asia-Pacific economic summit are trying to game out what Mr. Trump’s presidency will mean for trade with the world’s largest economy.