BAKU (Reuters) - A court in Azerbaijan freed human rights activist Ilgar Mammadov on Monday after he had served five years of a seven-year jail sentence which the European Court of Human Rights has described as “an unjustified restriction of freedom.”

Mammadov, leader of a rights group called Republican Alternative (ReAl), was convicted and sentenced in 2013 for organising and taking part in demonstrations in the northern town of Ismailli against a provincial leader.

Fellow activists and lawyers of the accused said at the time that the court’s verdict was politically motivated while the European Court of Human Rights said in May 2014 that the courts in Azerbaijan had violated Mammadov’s right to liberty.

The European court ordered the Baku government to pay him 22,000 euros ($30,000) in compensation and free him, though this never happened.

A court in Baku on Monday released him before the end of his sentence, putting him on probation for two years and banning him from leaving Azerbaijan, a Reuters correspondent reported from the court.

“I’m not happy with the decision of the court. This is not a complete, but a partial victory,” Mammadov told journalists at his home soon after the release.

The mainly Muslim country, sandwiched between Russia and Iran, has been governed by President Ilham Aliyev since he succeeded his father in 2003.

It has been courted by the West because of its role as a counter-balance to Russia for supplies of oil and gas to Europe, while rights groups accuse Baku of muzzling dissent and jailing opponents, charges which the government denies.