President Barack Obama on Wednesday urged Ukraine to avoid violence against peaceful protesters or face consequences, as the United States considered joining European partners to impose sanctions aimed at ending deadly street clashes that are sparking fears of civil war.

“There will be consequences if people step over the line,” Mr. Obama said shortly after landing in Mexico for a summit with the leaders of Mexico and Canada, as fires burned in central Kiev. “And that includes making sure that the Ukrainian military does not step in to what should be a set of issues that can be resolved by civilians.”

Shortly after Mr. Obama’s remarks, Ukrainian President Viktor Yanukovych’s office said he and opposition leaders had agreed on a truce, although the brief statement offered no details about what it would entail or how it would be implemented. Mr. Obama later responded that he hoped a truce would “provide space for the sides to resolve their disagreements peacefully.”

“Ultimately the government’s responsible for making sure that we shift toward some sort of unity government, even if it’s temporary, that allows us to move to fair and free elections so that the will of the Ukrainian people can be rightly expressed without the kinds of chaos we’ve seen on the streets, without the bloodshed that all of us, I think, strongly condemn,” Mr. Obama said at an evening news conference with his fellow North American leaders.

Meanwhile, the European Union called an extraordinary meeting of its 28 member countries on Thursday to address the situation.

French Foreign Minister Laurent Fabius told reporters in Paris that he and his counterparts from Germany and Poland would travel to Ukraine, meeting with the Ukrainian government and opposition before the emergency EU meeting. EU sanctions would typically include banning leading officials from traveling to the EU countries and freezing their assets there.

Mr. Obama said he is monitoring the Ukrainian violence “very carefully.”

“We expect the Ukrainian government to show restraint and to not resort to violence when dealing with peaceful protesters,” Mr. Obama said.

Secretary of State John Kerry, in Paris for meetings with Fabius and others, said he was disturbed by the level of abuse demonstrated by the Ukrainian government and protesters.

“We are talking about the possibility of sanctions or other steps in order to create the atmosphere for compromise,” he said.

It was not immediately clear Wednesday what sort of sanctions or penalties the U.S. could impose.

State Department deputy spokeswoman Marie Harf said visa restrictions already have been imposed against some members of the Ukrainian government, and cited “different kinds of individual sanctions that can be levied” without being specific. She said officials are still trying to determine who is responsible for the violence and described a sense of urgency within the Obama administration “to make decisions very, very soon about what we will do next.”

Deadly clashes between police and anti-government protesters in the Ukrainian capital of Kiev on Tuesday left at least 25 people dead and hundreds injured.

Ben Rhodes, Mr. Obama’s deputy national security adviser, told reporters travelling with Mr. Obama aboard Air Force one that what happened Tuesday was “completely outrageous” and will be a factor in U.S. decision-making.

Rhodes said there was still time for the Ukrainian government to avoid sanctions or other punishment by pulling back its “riot police,” respecting people’s right to protest peacefully, releasing protesters who have been arrested and pursuing a “serious dialogue” with the opposition about how to unify the country.

A senior State Department official, who is closely following the unrest in Ukraine, said Wednesday that U.S. officials were concerned about the Ukrainian president’s decision to replace the army chief. The military has announced that it would take part in a national anti-terrorist operation to restore order. U.S. officials have been able to stay in direct contact senior security force leaders in the Ukrainian government, but in the past 24 hours that has been difficult because they are not answering their phones, the official said.

The official was not authorized to be quoted by name and would brief reporters only on condition of anonymity.

In January, the U.S. Embassy in Kiev revoked existing visas of Ukrainians the U.S. suspected were complicit in violence against protesters in December. On Wednesday, the U.S. denied admission to the United States for about 20 individual Ukrainians the U.S. believes are responsible for the actions against the most recent violence Tuesday night in Kiev’s Independence Square, also known as the Maidan. This action means that if they were to apply for visas, they would be denied.

The official said these individuals represent the “full chain of command that we consider responsible for ordering security forces to move against the Maidan yesterday.”

On Capitol Hill, Sens. John McCain, R-Ariz., and Chris Murphy, D-Conn., said they were working on legislation that would impose narrowly focused sanctions against Ukrainians who have committed, ordered or supported acts of violence against peaceful protesters, or who are complicit in a rollback of Ukraine’s democracy.

“There must be consequences for the escalation of violence in Ukraine,” they said in a statement. “Unfortunately, that time has now come.”

Mr. Obama was asked at the news conference whether he sees Russia’s hand in the intransigence of the Ukrainian and Syrian governments and whether violent clashes in both countries have turned into a tug of war between the U.S. and Russia. Mr. Obama said although Russia clearly has influence with both governments, the turmoil has come from people voicing their desire for basic freedoms.

“Our approach in the United States is not to see these as some Cold War chessboard in which we’re in competition with Russia. Our goal is to make sure that the people of Ukraine are able to make decisions for themselves about their future,” he said.

More In: World | International | News