KIEV (Reuters) - In a week that has confused many Ukraine watchers, President Petro Poroshenko accused Moscow of launching "direct and open aggression" against his country and two days later said a peace process could begin as early as Friday.
As his office announced Poroshenko and Russia's President Vladimir Putin had reached agreement on a ceasefire in eastern Ukraine - a statement swiftly denied by Moscow - Ukraine's prime minister added to the confusion by branding Russia a "terrorist state" whose support for peace talks was just a sly ruse.
Then on Thursday, speaking on the sidelines of a NATO summit in Wales where he won fresh pledges of Western support, Poroshenko confirmed he would order a ceasefire on Friday if a proposed peace plan was signed in Minsk as expected.
The war in eastern Ukraine between Kiev's forces and pro-Russian separatists, in which more than 2,600 people have been killed, has dominated the first three months of Poroshenko's presidency.
But the president, whose forces recaptured swathes of land from the rebels this summer, seems to have accepted there can be no military victory and his cautious, zigzagging shift towards a ceasefire reflects both battlefield realities and domestic politics ahead of a parliamentary election on Oct. 26.
"Poroshenko had a plan to free Donetsk and Luhansk (the main eastern cities in rebel hands) before the elections, to be a victor. The plan has not worked. Putin has not allowed it," said political analyst Volodymyr Fesenko.
"It has become obvious that instead of winning the war he could lose it. This is a big risk and for Poroshenko it is better to agree on a ceasefire, cement this hard-won battlefield 'draw' and give a chance for the elections to take place."
Kiev and its Western supporters say Russia has rescued the rebels from imminent military defeat by sending its own troops and more weapons into eastern Ukraine - accusations rejected by Moscow, which denied on Wednesday agreeing to a ceasefire on the grounds that it is not a party to the conflict.
"Poroshenko is a realist and a pragmatist ... He understands he has little time, that he needs to tackle the economy and to end the war more quickly," said Fesenko, referring to the abysmal state of an economy kept afloat with IMF credits.
The former confectionery magnate now expects envoys from Ukraine, Russia and Europe's OSCE security watchdog to work out a peace plan at their talks in Minsk on Friday.
The risks for Poroshenko, 48, could just be starting, however. If he is seen by Ukrainians to be accepting peace on Moscow's terms, he will lay himself open to attack by the many politicians in Kiev and beyond who say Putin cannot be trusted and his real aim is to destroy Ukraine.
"The last ceasefire lasted 10 days but there were more than 100 attacks during that time," said Otilia Dhand, an east Europe analyst at London-based risk consultancy Teneo Intelligence.
It was unclear whether Moscow and Kiev could rein in radicals on both sides, she said, and any attempt to turn a ceasefire into a durable political settlement was also risky because it could entail Poroshenko's acceptance of a "frozen conflict" in eastern Ukraine.
Support for a ceasefire appears very limited among both camps in eastern Ukraine, where many people accuse Ukraine's forces of shelling them indiscriminately and see the separatist commanders as their defenders.
"Ukraine is attacking and shelling us ... The Donetsk People's Republic help us and try to rid Donetsk of these idiots," said pensioner Nikolai, referring to the new "state" proclaimed in April by the separatists.
Opinion polls suggest a majority of Ukrainians still supports what Kiev calls its "anti-terrorist operation" against the separatists, leaving Poroshenko little room for manoeuvre in talks with Moscow and the rebels.
Prime Minister Arseny Yatseniuk, with an eye on the election, is playing to that constituency with his anti-Russian rhetoric. On Wednesday, he said the peace plan outlined by Putin was an attempt to deceive Kiev and the West.
Political analysts expect Yatseniuk to become a leading figure in a new "patriotic" party that will bring together disaffected supporters of ex-prime minister Yulia Tymoshenko, who lost the May presidential election to Poroshenko.
Such a party, pro-European and liberal in its economic views, would be a natural ally for Poroshenko, and Fesenko played down talk of a rift between Yatseniuk and the president, saying they were playing a "hard cop, soft cop" routine.
"Poroshenko will be the peacemaker and Yatseniuk will present himself as the supporter of a more belligerent position. We will have hard and soft - they will cover the whole spectrum of voters and thus neutralise Tymoshenko."
But Poroshenko needs to tread carefully. If he appears too keen to mend fences with Moscow, he will lose support to nationalist parties, especially in western Ukraine. And nobody in Ukraine has forgotten the fate of his predecessor.
Support for closer European ties and distrust of Russia are strongest in the more nationalist-minded, Ukrainian-speaking western regions, while the east is mainly Russian speaking and has strong economic and cultural links with Russia.
Western Ukrainians played a prominent role in the protests against Ukraine's former president, Moscow-backed Viktor Yanukovich, who came from the eastern Donetsk region. He fled into exile in Russia in February, prompting Moscow to seize Ukraine's Crimea region and igniting the revolt in the east.
"Poroshenko has clearly defined his red lines beyond which Ukraine will not go - the internal state structure of Ukraine, the European orientation of the country and Crimea," said analyst Mykhailo Pashkov.
"The goal of the Ukrainian side is to end the military operations while protecting Kiev's national interests."
(Additional reporting by Gabriela Baczynska in Donetsk; writing by Gareth Jones; Editing by giles Elgood)