KYIV, Jan 19 (Reuters) - Former Ukrainian president Petro Poroshenko won a court ruling on Wednesday allowing him to remain at liberty while being investigated for treason in a probe he says was cooked up by allies of his successor, President Volodymyr Zelenskiy.
Dressed in a traditional embroidered shirt, Poroshenko appeared in court while thousands of his supporters demonstrated outside, chanting and waving flags and briefly scuffling with police before the hearing.
Critics say the case is an ill-judged distraction at a time when Ukraine is bracing for a possible military offensive by Russia.
Poroshenko, 56, is being investigated in connection with the financing of Russian-backed separatist fighters through illegal coal sales in 2014-15.
He faces up to 15 years in prison if found guilty, and his party accused Zelenskiy of a reckless attempt to silence opposition.
Zelenskiy's administration says the prosecutors and judiciary are independent and accuses Poroshenko of putting himself above the law.
"This is not yet a victory, this is the first step in the right direction," Poroshenko said.
A judge rejected the state prosecutor's request to have Poroshenko detained, although the ex-president was ordered to stay in Kyiv and had to hand over his passport.
Poroshenko said he had invitations to at least three foreign visits, and would appeal.
"The seizure of my passport hinders my political activity. Being limited to staying in Kyiv hinders my internal political activity."
He sang the national anthem inside the court after the hearing before joining his supporters outside. A crowd then began marching towards the president's office.
Zelenskiy trounced Poroshenko in an election in 2019, running on a ticket of tackling corruption and curbing the influence of oligarchs in the former Soviet republic.
U.S. Secretary of State Antony Blinken, meeting Zelenskiy in Kyiv, appealed to Ukrainian leaders to present a united front against Russia.
"I think one of Moscow's long-standing goals has been to try to sow divisions, between and within countries, and quite simply we cannot and will not let them do that," he said.
Poroshenko also called for unity, saying: "The behaviour of the aggressor requires a national consensus."