A Moscow court has rejected Russian opposition leader Alexei Navalny’s appeal against his prison sentence.

The Moscow City Court’s ruling came even as the country faced an order from the top European rights court to free the Kremlin’s most prominent foe.

A lower court sentenced Navalny earlier this month to two years and eight months in prison for violating the terms of his probation while recuperating in Germany from a nerve agent poisoning that he blames on the Kremlin.

Russian authorities have rejected the accusation.

Navalny, 44, an anti-corruption crusader and President Vladimir Putin’s most vocal critic, appealed against the prison sentence and asked to be released.

The Moscow City Court judge on Saturday only slightly reduced his sentence to just over two-and-a-half years in prison, ruling that a month-and-a-half Navalny spent under house arrest in early 2015 will be deducted from his sentence.

Speaking before the verdict, Navalny referenced the Bible as well as Harry Potter and the animated sitcom Rick And Morty as he urged Russians to resist pressure from the authorities and challenge the Kremlin to build a fairer and more prosperous country.

“The government’s task is to scare you and then persuade you that you are alone,” he said.

“Our Voldemort in his palace also wants me to feel cut off,” he added, in a reference to President Vladimir Putin.

“To live is to risk it all,” he continued.

“Otherwise, you’re just an inert chunk of randomly assembled molecules drifting wherever the universe blows you.”

Navalny also addressed the judge and the prosecutor, arguing that they could have a much better life in a new Russia.

“Just imagine how wonderful life would be without constant lying,” he said.

“Imagine how great it would be to work as a judge when no-one would be able to call you and give you directions what verdicts to issue.”

Navalny’s arrest and imprisonment have fuelled a huge wave of protests across Russia.

Authorities responded with a sweeping crackdown, detaining about 11,000 people, many of whom were fined or given jail terms ranging from seven to 15 days.

Russia has rejected Western criticism of Navalny’s arrest and the crackdown on demonstrations as meddling in its internal affairs.

In a ruling on Tuesday, the European Court of Human Rights ordered the Russian government to release Navalny, citing “the nature and extent of risk to the applicant’s life”.

The Strasbourg-based court noted that Navalny has contested Russian authorities’ argument that they had taken sufficient measures to safeguard his life and wellbeing in custody following the nerve agent attack.

The Russian government has rebuffed the Strasbourg-based court’s demand, describing the ruling as unlawful and “inadmissible” meddling in Russia’s affairs.

Opposition leader Alexei Navalny stands in a cage in the Babuskinsky District Court in Moscow
Alexei Navalny stands in a cage in Babuskinsky District Court in Moscow (Alexander Zemlianichenko/AP)

In the past, Moscow has abided by the ECHR’s rulings awarding compensations to Russian citizens who have contested verdicts in Russian courts, but it never faced a demand by the European court to set a convict free.

In a sign of its long-held annoyance with the Strasbourg court’s verdicts, Russia last year adopted a constitutional amendment declaring the priority of national legislation over international law.

Russian authorities might now use that provision to reject the ECHR’s ruling.

Later, Navalny will also face proceedings in a separate case on charges of defaming a Second World War veteran.

Navalny, who called the 94-year-old veteran and other people featured in a pro-Kremlin video “corrupt stooges”, “people without conscience” and “traitors”, has rejected the slander charges and described them as part of official efforts to disparage him.