Ukraine's imprisonment of the former prime minister Yulia Tymoshenko was a politically motivated violation of her rights, Europe's human rights court has ruled.

A Ukrainian ambassador stormed out of the court in response to the ruling in a case that has strained the former Soviet state's ties with Europe and the US.

An architect of the 2004 pro-democracy Orange Revolution, instantly recognisable by her crown of braids, Tymoshenko was sentenced to seven years in prison in October 2011 after being convicted of exceeding her powers as premier while negotiating a gas contract with Russia.

Tymoshenko has said her detention was intended to keep her out of politics and that her rights were violated when she was first imprisoned in August 2011. The court agreed unanimously that she had been jailed "for other reasons" than those permissible by law.

"It was not a criminal prosecution. There was another aim of that prosecution and everyone knows that that was a politically motivated prosecution," said Serhiy Vlasenko, Tymoshenko's lawyer.

He said the court found "the prosecution of Mrs Tymoshenko in Ukraine had nothing to do with the law, had nothing to do with democratic standards, had nothing to do with a criminal prosecution".

It is unclear how a decision by the European court would be legally binding in Ukraine.

In Kiev, the government representative at the European court of human rights, Nazar Kulchitsky, told Interfax news agency that the Ukrainian government needed time to study the ruling, but suggested the government might appeal against it.

Tymoshenko and her allies, including Vlasenko, who was expelled from parliament, say her conviction was masterminded by President Viktor Yanukovych, who is intent on keeping her locked in jail, away from politics and out of last year's parliamentary elections and the 2015 presidential election.

Yanukovych said this was a legal matter and could not interfere. Over the weekend, a presidential pardon commission said it would not consider a motion to pardon Tymoshenko while other legal cases against her were ongoing, including some that could take years to resolve.

The dilemma faced by the west is whether to bring Ukraine closer into its fold, despite Tymoshenko's case, or risk seeing the country move towards Russia.

Vlasenko called for Tymoshenko to be freed immediately, saying it was the only way to restore her rights. "She is under 24-hour a day, seven days a week, 365 days a year psychological pressure," he said.

If the decision is upheld on appeal, Tymoshenko's legal team could petition Ukraine's supreme court to annul Tymoshenko's conviction and sentence on the grounds that it was issued by the same judge who ordered her arrest.

Andriy Kozlov, an independent legal expert, said that while Ukraine's supreme court would be required to review Tymoshenko's case, it would not necessarily be obliged to overrule the decision by the local courts.

In Kiev, a handful of Tymoshenko supporters in tents outside the court where she was convicted reacted with joy but said they did not believe the government would release her. "Yanukovych has always been afraid of her," said Oleksiy Karaulny, 63, a retired carpenter. "Of course we are happy. And it's not only me who is happy, it's all the 12 million people who voted for her are also happy. They know that truth will come, that justice will prevail."