The decision to deploy riot police against the long-running political protest here, under cover of darkness, and then to pull them out 10 hours later has left the Ukrainian government struggling to find a footing at home and abroad.

President Viktor Yanukovych has greatly lifted the morale of his opponents with the seemingly ferocious but ultimately unfruitful police action and has created a new set of heroes: the veterans of the Soviet war in Afghanistan who faced down armored Ukrainian officers. And he sat down with two Western diplomats who made their displeasure evident.

“I made it absolutely clear to him that what happened last night, what has been happening in security terms here, is absolutely impermissible in a European state, in a democratic state,” Victoria Nuland, the U.S. assistant secretary of state for European and Eurasian affairs, said Wednesday after meeting with Yanukovych.

“But we also made clear that we believe there is a way out for Ukraine, that it is still possible to save Ukraine’s European future, and that is what we want to see the president lead,” she said.

The dispute that has engulfed Ukraine started with Yanukovych’s last-minute decision to spurn an agreement with the European Union and instead seek closer economic ties to Russia. Opposition political parties and hundreds of thousands of Ukrainians have shown that they disagree with the decision and have maintained a fluctuating but continual presence on Kiev’s Independence Square since late November.

Ukraine is heading for a default in early 2014 if it cannot secure financial assistance. The fumbled use of police has appalled Western governments — Secretary of State John F. Kerry said the United States viewed it with “disgust” — and will not make it any easier for Yanukovych to negotiate better terms with Russia, which will sense his weakness.

Jen Psaki, a spokeswoman for the State Department, said Wednesday that the United States was considering various responses, including sanctions.

Kerry’s statement went much further than previous U.S. comments and made clear that attempts to appeal to the Yanukovych government for restraint had fallen short. The strong words also marked a departure from U.S. attempts to keep the issue from stoking tension with Russia.

“This isn’t about the U.S. versus Russia,” Psaki said. “This is about Ukraine and the voices of the people in Ukraine and what they’ve expressed to the government.”

Also Wednesday, Defense Secretary Chick Hagel spoke with his Ukrainian counterpart, Pavel Lebedev, and warned him against using the military to break up the protests.

The opposition has called for the release of all political prisoners. (Five students arrested Nov. 30 in a police assault have since been released.) It also wants Prime Minister Mykola Azarov replaced. Under those conditions, political leaders had said, they might accept Yanukovych’s invitation to roundtable negotiations.

But that was before Wednesday’s police incursion. Yanukovych would now need to impress them with uncharacteristic sincerity to get them to sign on.

“For the sake of compromise I urge the opposition not to give up, do not go down the path of confrontation and ultimatums,” he said in a statement on his Web site. “Be assured that the government will act only within the law and never will use force against peaceful demonstrations.”

But Vitali Klitschko, a former boxer and rising political star in the opposition, said that with the police action, “Yanukovych closed off the path to any kind of compromise.”

The president also talked about finding a deal with the E.U. after all. Catherine Ashton, the E.U.’s foreign affairs chief, met with him Wednesday for the second time in two days and said afterward that he promised to act within 24 hours.

Sergei Zinchenko, 52, of Lugansk was among 50 or so veterans of the Soviet-Afghan war who have been camped on Independence Square and who confronted the special police force, the Berkut, on Institutska Street. They placed themselves in front of a makeshift barricade while other protesters stayed behind it.

“We didn’t allow the young people to come around to that side,” he said later. “If the Berkut was going to beat anyone, they could beat us.”

The vets, known as Afghantsi, held off the police. Zinchenko got a crack in the ribs for his efforts.

“For several hours, they were the only force protecting the people,” said Vasyl Feduk, 29, a tour guide from western Ukraine who was standing behind the barricade.

Finally, the Afghantsi retreated, the police cut through the barricade, and more than an hour of pushing back and forth ensued. Feduk said it gradually became clear that neither side wanted to hurt the other for fear of escalation.

It was a good thing, too, he said, because with police forces pushing toward the square from four directions, they could have caused considerable mayhem if given the order to lash out.

The interior minister, Vitali Zakharchenko, said the police were sent in not to clear the square but to reopen streets that run along it. The protesters expressed skepticism. In any case, when the police pulled out about 11 a.m., the streets were quickly taken back by the opposition.

Zinchenko said it was too early to call it a victory. He says the police will probably be back. Another protester, Viktor Pogorelov, 64, said of Yanukovych, “A wounded animal is the most dangerous.”

By Wednesday evening, the protesters, whose numbers had swelled as Kievans started flocking to the square before dawn when they heard the news of the police incursion, had built formidable packed-snow barricades to replace those destroyed by the police.