Kim Sengupta: 'My trial was a farce,' Pervez whispered from his prison cell

I first met Pervez Kambaksh during a visit to Kabul in the spring of 2007. He was training to be a journalist and said he was looking forward to exposing corruption and uncovering human-rights abuses in his country.

Pervez was keen to go down to Helmand to the thick of the fighting to cut his reporting teeth. His family, however, were not keen.

We lost contact after that but in January last year I received a phone call in London with the staggering news that Pervez had been sentenced to death by an Islamic court. When this newspaper published the news, there was widespread condemnation. Yaqub Ibrahimi, Pervez's brother, contacted me. He was frantically trying to organise a campaign inside Afghanistan. Luckily, the international furore began to grow.

In February 2008 I visited Balkh prison in Mazar-i-Sharif, and saw Pervez. He was sharing a 10mx12m cell with 34 others – murderers, robbers and terrorists – and looked frail and depressed. His court appearance, he whispered through the bars, had been a "farce". "What they call my trial lasted just four minutes in a closed court. I didn't have a lawyer, I wasn't allowed to speak, I was told I was guilty and the decision was that I was going to die."

During a second visit to the prison we were spotted, arrested, and taken before the governor. Much to my surprise General Taj Mohammed, chief of the prison service for northern Afghanistan, said he believed what happened to Pervez was "very wrong". "He is a young man and he does not deserve to die," he said.

Pervez was eventually moved to Kabul and began the appeals process. I went to some of the hearings, which seemed arbitrary and weighted against the defendant. It was difficult to find lawyers for him as they tended to receive death threats. But the evidence against the student seemed to get increasingly weaker: some of the prosecution witnesses withdrew their testimony, and my colleague, Jerome Starkey, found the author of the article at the centre of the case, disproving the prosecution case that Pervez had written it himself. At the final hearing the death sentence was set aside, but instead he was sentenced to 20 years. Pervez tried to put on a brave face. "At least I am not going to die," he said. "But 20 years is a long time, I can mark the days on the wall as they do in the films, but I'll run out of space."

Then, at last, there was some light in the tunnel. Negotiations were going on behind the scenes, I heard from a diplomatic source, and President Karzai was slowly being persuaded that he must correct this injustice. Would he, however, take the risk of inflaming conservative Muslim opinion, and risk losing votes, so close to the election? Evidently he did. Pervez is free. It is unlikely he will ever fulfil his journalistic ambitions. But he is, at least, out of harm's way.