LOS CABOS, Mexico — President Obama and Russian President Vladimir Putin agreed Monday that Syrians should choose their own next government, marking a subtle shift for both the United States and Russia as they confront the prospect that Russia’s main ally in the Mideast could slide into civil war.

Sharing pledges of common ground, yet hardly much eye contact or obvious kinship in front of reporters, Obama and Putin met for the first time since the Russian leader returned to the presidency last month.

Obama spoke at greater length, emphasizing several areas of cooperation between the onetime Cold War enemies, but the prospect of unending bloodshed in Syria hung over the talks.

The two leaders “agreed that we need to see a cessation of the violence, that a political process has to be created to prevent civil war and the kind of horrific events that we’ve seen over the last several weeks,” Obama said. Putin, seated next to Obama after the private meeting, said: “We’ve been able to find many commonalities” on Syria.

But he offered no specifics on what those were, and it was unclear how much the closed two-hour talk did to close strategic gaps about how to end the violence.

Russia has refused to call for the ouster of Syrian President Bashar Assad, an ally, and neither leader mentioned him by name Monday.

In a departure from previous statements, Obama called for a “political process” that would end horrific violence in Syria, but he did not say Assad must go.

Obama’s careful language appeared designed to give the Russian some elbow room. In other settings, he and other White House officials have been forceful in insisting that Assad must step aside.

Obama and Putin had a brisk handshake at the end, and their tones were cool.