Someone should write a black comedy based on the Pussy Riot trial that's been amusing and appalling journalists in Moscow all week.

If the wheels of Russian justice weren't grinding so mercilessly towards a monstrous conclusion, you would be rolling with laughter.

It's been called a show trial, designed to intimidate Russia's burgeoning opposition movement, but at times it was more like an episode of Blackadder.

To recap. Pussy Riot are an anarchic, feminist, punk performance-art band (I think that sums up their attributes). Three members – Nadezhda Tolokonnikova, 22, Maria Alyokhina, 24, and Yekaterina Samutsevich, 29 – are on trial for hooliganism "committed on the grounds of religious hatred", after a 90-second performance in Moscow's Christ the Saviour cathedral in February.

Dressed in lurid tights, short dresses and balaclavas, they jumped around the altar singing a raucous "punk prayer" entitled Holy Shit, enjoining the Virgin Mary to rid Russia of Putin. Not the most subtle of protests, not exactly sensitive to the feelings of believers, certainly, but no-one was harmed, no property damaged, and the church was almost empty at the time.

Yet the women, who have already spent five months in jail awaiting trial, could face a sentence of seven years for this "crime". Two of them have young children, whom they have not been allowed to see since their arrests – even though they are allegedly "innocent until proved guilty".

The judge, Marina Syrova, in timeworn Russian tradition, is clearly intent not on establishing the truth but on proving the defendants' guilt. She cuts them off in mid-sentence, overrules questions, and leads the witnesses towards the required testimony. The witnesses (or "victims") include an elderly lady who sells candles in the church, another who works as a concierge and an altar-boy, all of whom were traumatised by the performance. (Their written testimonies contain identical phrases, apparently cut and pasted from the prosecution's charge sheet).

Do the women "cross themselves as all citizens do?" the judge asks. Could they, in fact, be possessed by the devil? Well, says a witness, like a straw-chewing yokel at a mediaeval witch-trial, they flailed their arms about and kicked their legs high in the air as if possessed. (The official charge is that they "started to satanically jerk around, jump, run, kick their legs up, and twirl their heads while they shouted very insulting, blasphemous words".)

But how could the witness be sure that Nadezhda Tolokonnikova was really one of the three who had desecrated the church? She was, after all, wearing a balaclava.

"Ahaaah!" says the witness (imagine Baldrick suddenly illuminated by a brilliant idea), "you could identify her by the structure of her calf muscles!"

Pussy Riot exploded onto the scene as the most colourful element of the protest movement spawned by last December's fraudulent parliamentary elections, and Vladimir Putin's decision to return to power for a third term as president.

Their stunts included a brief performance in Red Square in January: the sight of six women in bright-coloured balaclavas and dresses dancing and singing on a snow-covered wall, roaring protest up at Putin's windows in the Kremlin, was a first for Russia, and earned them small fines for breaching the peace.

Had they been given a fine for their cathedral performance too, no-one would have taken much notice. But the video of the event went viral on YouTube, and the threat of a seven-year sentence has caused a worldwide uproar. Politicians and musicians from Franz Ferdinand to Sting have demanded their release.

The trial – intended by Putin or his acolytes as a warning to the growing protest movement – has turned into a spectacular own goal, strengthening the view that Putin's Russia is sinking deeper into an authoritarian swamp. The women come to court guarded and handcuffed like dangerous criminals. Their faces, photographed in their glass courtroom cage, have become emblems of injustice.

This is the first overtly political trial in Putin's Russia. When businessman (and Putin critic) Mikhail Khodorkovsky was jailed, the courts tried to apply a veneer of "respectability" to the case: Khodorkovsky was convicted and jailed for economic, not political crimes. With Pussy Riot, it is all about words – sung or shouted, perhaps, in an offensive manner, but causing no criminal damage to anyone. They are on trial for carrying out a peaceful protest.

The point of the prank in the cathedral, according to Tolokonnikova's husband, Pyotr Verzilov, was "to draw attention to the links between the Orthodox Church and the Kremlin". Ever since the collapse of the atheist USSR, the church has been undergoing a revival, and plays an increasingly important role in public life. Putin himself, though once a member of the KGB which imprisoned church activists, says he is a devout believer. It was his story of salvaging a silver cross from a burned-down house that so impressed President George W Bush on their first meeting.

As Putin and his protégé Dmitry Medvedev turn up in church for all the main holy days, and promise millions to build churches, so the church returns the favour. Patriarch Kirill endorsed Putin's candidacy in the recent presidential election, calling his time in office a "divine miracle". Kirill was incensed by Pussy Riot's "punk prayer", and it was the church that led the charge against the women, presumably sensing that it was acting in the spirit of a recent Kremlin crackdown on dissent.

After a brief "thaw" over the winter, when huge demonstrations were permitted in Moscow, Putin's re-election in March led to a series of repressive measures that clearly demonstrated the president's determination to keep the lid on the protest movement. Just before the summer recess, the Russian parliament rushed through a raft of laws that can be seen as turning the screws on the opposition.

Participation in an unsanctioned street protest can now incur prohibitive fines; defamation (decriminalised by President Medvedev half a year ago) has been designated as a crime once more; the authorities have the right to impose restrictions on the internet; and NGOs that receive money from abroad (including, for example, election monitoring groups) must now register as "foreign agents".

There were raids on the flats of opposition leaders, and one of the most prominent, Aleksei Navalny, was last week charged with embezzlement – after a case that had earlier been closed for lack of evidence was reopened at the Kremlin's behest.

And yet, in London on Thursday last week, something unexpected happened. Feeling generous, perhaps, after watching Russia's judo champion win an Olympic gold medal, Putin remarked that the Pussy Riot women "should not be judged too harshly". Poor Judge Syrova, who had seemed to be paving the way for the harshest judgment, must have been close to fainting.

Putin's off-the-cuff comments are never off-the-cuff. When he mentioned, just before the end of the Khodorkovsky trial, that "a thief should sit in jail", Khodorkovsky was duly sentenced to seven more years in prison. When Putin mentioned that, of the various animals proposed to be chosen in a TV vote as mascot for the Winter Olympics to be held in Russia in 2014, his favourite was the snow leopard – lo and behold the TV audience voted for the snow leopard. There is little doubt the judge will have heard her master's voice and will opt for a lenient sentence for the Pussy Riot trio – though any sentence at all will be scandalous.

So what's going on? Was Putin never behind the trial at all, or was he happy to let the church stir up a frenzy of expectation, so he could look better by backing off?

My theory is this. In Putin's world some people in powerful positions think it's okay to commit appalling acts that they think will please Putin. In the atmosphere he has created they can get away – in some cases literally – with murder. The journalist Anna Politkovskaya was killed on Putin's birthday – almost certainly not on Putin's orders but quite possibly by some benighted individual who thought he was giving the leader a nice gift. KGB man-turned-dissident Alexander Litvinenko was poisoned in London, according to British investigators, by Russian agents – also, perhaps, to "please" Putin, though almost certainly not on his direct orders.

In the Pussy Riot case, Patriarch Kirill – and the prosecutor and judge – perhaps saw a chance to ingratiate themselves by persecuting three young women who campaigned against Putin. In all these cases, Putin can suggest leniency, or feign shock and indignation, making himself appear more human, while still reaping the benefit of a show trial calculated to instil fear.

If the judge does show leniency, of course, it will once again demonstrate the abject dependency of the Russian court system. Russians call it "telephone law" – the judge does whatever he or she is instructed to do in a call from above. In the new Putin-era version, there is no actual telephone call, just a nod and a wink or a perfectly-timed remark to a journalist.

Meanwhile, in Moscow's Khamovnichesky court, the comedy continues. A verdict may come next week.