By Richard Balmforth and Natalia Zinets

KIEV (Reuters) - Western powers threatened sanctions on Wednesday over the death of 26 people in the worst violence since Ukraine's independence from the Soviet Union, pressuring President Viktor Yanukovich to compromise with his pro-European opponents.

Yanukovich, backed by Russia, denounced the overnight bloodshed in central Kiev as an attempted coup, and his security service said it had launched a nationwide "anti-terrorist operation" after arms and ammunition dumps were looted.

In the western bastion of Ukrainian nationalism, a regional assembly declared self-rule and crowds seized public buildings.

U.S. President Barack Obama said he condemned the violence in the strongest possible terms and warned of consequences if it continued, while European Union leaders said they were preparing targeted sanctions against those responsible for the "unjustified use of excessive force by the Ukrainian authorities".

EU officials said Yanukovich himself would not be on the list to keep channels of dialogue open. The foreign ministers of Germany, France and Poland will visit him on Thursday, hours before an emergency EU meeting to decide on the sanctions.

The United States, going head to head with Russia in a dispute heavy with echoes of the Cold War, urged Yanukovich to pull back riot police, call a truce and talk to the opposition.

Pentagon spokesman Colonel Steve Warren urged the Ukrainian armed forces to stay out of the conflict, warning that "participation would have consequences in our defense relationship".

Earlier on Wednesday, Ukraine's defenCe ministry said the armed forces might take part in a countrywide anti-terrorist operation organised by the state security service.

A presidential decree later appointeD a new head of the armed forces general staff, naming navy head Admiral Yury Ilyin in place of Colonel-General Volodymyr Zamana. The decree gave no explanation for the change in personnel, nor for the timing.

IF DIALOGUE FAILS

While U.S. President Obama said he believed a peaceful resolution was still possible, Poland's prime minister, Donald Tusk, spelled out the alternatives if dialogue fails.

"What if no compromise is achieved?" he asked in parliament. "We will have anarchy and perhaps division of the state or civil war, the beginning of which we may now be witnessing."

Protesters have been occupying central Kiev for almost three months since Yanukovich spurned a far-reaching trade deal with the EU and accepted a $15-billion Russian bailout instead.

The sprawling nation of 46 million, with an ailing economy and endemic corruption, is the object of a tug-of-war at a global level between Moscow and the West. But the struggle was played out at close quarters, hand to hand, in fighting through the night on Kiev's Independence Square, or Maidan.

After night fell, fires blazed along the barricaded frontline between the protesters and riot police, but there was no immediate sign of a repetition of Tuesday's violence.

Russian President Vladimir Putin and Yanukovich spoke by telephone during the night and both denounced the events as an coup attempt, a Kremlin spokesman said.

Russian Foreign Minister Sergei Lavrov blamed the West for encouraging opposition radicals "to act outside of the law".

Moscow announced on Monday it would resume stalled aid to Kiev, pledging $2 billion hours before the crackdown began. The money has not yet arrived and a Ukrainian government source said it had been delayed till Friday "for technical reasons".

Ukraine's hryvnia currency, flirting with its lowest levels since the global crash five years ago, weakened to more than 9 to the dollar for the second time this month.

BATTLE ZONE

After a night of petrol bombs and gunfire on Independence Square, a trade union building that protest organisers had used as a headquarters stood blackened and gutted by fire.

Security forces occupied about a third of the square - the part that lies closest to government offices and parliament - while protesters reinforced their defences on the remainder of a plaza they have dubbed "Euro-Maidan".

In a statement posted online in the early hours, Yanukovich said he had refrained from using force during three months of unrest but was being pressed by "advisers" to take a harder line: "Without any mandate from the people, illegally and in breach of the constitution of Ukraine, these politicians - if I may use that term - have resorted to pogroms, arson and murder to try to seize power," the president said.

Story continues