Confined in a glass box in a Moscow courtroom, Alexei Navalny berated the judge, mocked a prison official and sparred with the prosecutor.

Then, at the end of a long day in court, President Vladimir Putin's fiercest critic showed his softer side, smiling at his wife Yulia and drawing a heart on the glass of his cage.

Since his arrest in mid-January after returning from Germany where he was treated for a poisoning, Navalny has turned a series of hearings at Russia's usually colourless courtrooms into headline-grabbing acts of political theatre.

In turns defiant, mocking, and affectionate, the 44-year trained lawyer has used the court appearances to build up his support, infuriate his opponents and craft an image as Russia's preeminent political prisoner.

Navalny turned his February 2 hearing -- when a judge ordered him jailed for nearly three years on old fraud charges -- into a blistering attack on Putin.

Mocking the Russian leader over allegations the Novichok nerve agent used to poison him had been placed in his underwear, Navalny told the court that Putin would "go down in history as a poisoner of underpants".

Navalny has turned a series of hearings at Russia's usually colourless courtrooms into headline-grabbing acts of political theatre
Navalny has turned a series of hearings at Russia's usually colourless courtrooms into headline-grabbing acts of political theatre Moscow's Babushkinsky district court press service / Handout

He sparred with officials and prosecutors in court, mocking their claims that he should have turned up for parole appointments by pointing out that he was in a coma.

His making of heart signs for his wife, shortly before judge Natalya Repnikova read the sentence, was splashed across newspapers around the world.

Much of what Navalny does in court is carefully calculated, said Moscow-based political observer Konstantin Kalachev, comparing his February 2 speech to that of a revolutionary in Tsarist Russia.

"He's working on his image," said the head of the Political Expert Group.

But some of Navalny's outbursts in court are clearly impulsive, Kalachev added.

Alexei Navalny inside the courtroom
Alexei Navalny inside the courtroom Babushkinsky District Court

"We are all human, and sometimes he gets carried away by his emotions," he said.

Days after being handed the prison term, Navalny went on trial again on charges of defaming a World War II veteran, part of a group of Russians in a pro-Kremlin video who Navalny described as "traitors".

He once again stole the show, mocking the judge and clashing with relatives of the veteran, whose family he accused of being "political prostitutes" and using the 94-year-old.

Judge Vera Akimova at one point threatened to remove Navalny from the courtroom and the hearing was suspended when the veteran said he felt unwell and an ambulance was called.

Navalny was back in court on Friday for the next hearing in the defamation case, showing no signs of backing down as he berated the judge.

"Stop shaming yourself and enrol in some courses to improve your knowledge of the laws of the Russian Federation," Navalny said, backing a request from his lawyer for the judge to be replaced.

If the February 2 hearing was a piece of political drama, then the defamation trial has become a comedy, said political analyst Anton Orekh.

But the appearances are also Navalny's only chance to keep up his fight against the authorities.

"If you don't have an opportunity to take part in polls and speak in parliament, if you don't have an opportunity to peacefully take to the streets and express your feelings and thoughts, if you have been stripped of access to state TV channels, the only thing that remains is a courtroom stand," Orekh wrote on his blog.

Since emerging as the Kremlin's top critic a decade ago, Navalny has stood in stark contrast to Putin and painted the 68-year-old as out of touch.

In the age of social media, Navalny's courtroom theatrics are especially appealing to young Russians, Kalachev said.

Navalny "speaks the same language as young people, they can see themselves in him," Kalachev added. "His clothes, his tastes, his wife, his family... he represents the urban middle class."