The Kenyan novelist Ngugi wa Thiong’o is rarely mentioned without a reference to the Nobel Prize.

He has not – as yet – won it, but he is held in such reverence and respect that it is widely assumed he one day will. Does it matter if it never comes his way? It is hard to know what this self-deprecating and humorous novelist would think, but for his readers and admirers, the prize would merely confirm his standing as a pre-eminent writer and thinker who has endured much for his art, and for his beliefs. Other perhaps than international publicity, it would confer nothing he does not already possess.

Ngugi wa Thiong’o is not a man to court the establishment, be it literary, religious or political. Revered as arguably Kenya’s most notable writer, he was once such a thorn in the flesh of the government that he was incarcerated for a year in Kamiti Maximum Security Prison in 1977-8. His crime? To write a play about Kenyan peasants, performed by Kenyan peasants, which gave them a political and artistic voice which, until then, they had never had. The play was called Ngaahika Ndeenda (I Will Marry When I Want) and, as Ngugi recalls dryly in his memoir of that terrible year, Wrestling with the Devil, he initially thought the government would praise him for it. He can laugh now.

The authorities’ outlook was chilling: “What right had a university professor to work with ragged-trousered workers and tattered peasants and even ‘pretend’ to be learning from a people whose minds we have decreed should never rise above the clods of clay they daily break? What is he really up to? Let us thwart his intentions – whatever they are. Incarcerate the clever fellow!”

Ngugi wa Thiongo’s appearance at the Edinburgh International Book Festival next week is a coup, this being only his second visit. I remember his first, in 2006, when he captivated his audience with a bravura performance as he discussed his novel, Wizard of the Crow. I queued to have a copy signed, but the line was too long, and I was too bashful, to start a conversation. Recently, however, I had the chance to speak to him when we met at the Auckland Literary Festival, where we were doing an event together about our favourite books.

Now 80, Ngugi is not a tall man, but his personality gives the impression of stature. He had flown to New Zealand from America, where he is Professor of English and Comparative Literature at the University of California, and when we first met, at a Maori greeting ceremony, he was recovering from the flight. By the time of our event, however, he was in fine form, having the day before filled a hall of 2000 who listened, captivated, as he discussed his life and career. Much of that discursive but entertaining hour was spent describing his early education, and his mother’s insistence that he learn as much, and do as well, as he could. For our session, he was armed with a list of five books he wanted to share with his audience. One of them was a detective novel written by his son – one of seven children. Among my selection was Robert Louis Stevenson’s Treasure Island, at which he enthusiastically agreed. As a boy, it had made a huge impression on him.

Earlier, on discovering I come from Scotland, he broke into a smile. He recalled his time here, in the mid-1960s, during a three-year scholarship at Leeds university. He told me that it was as he sat by the window on a cold train from Aberdeen to Edinburgh that he started to write his novel, A Grain of Wheat. He likes to write on the move. Even today, he enjoys flying because of the acres of empty time it involves, hours he spends writing, heedless of the tannoy system. Once, he nearly missed his flight as a result.

A Grain of Wheat, which began life as he looked out on to our grey east coast, and was published in 1967, marked a new direction in his politics, as he embraced Marxism. It is hard to imagine a greater contrast to Scotland in the age of the Beatles than Kenya under the rule of Kenyatta. They were more than a continent apart; a whole world separated them, for these were the years when the Kenyan Land and Freedom Army – known as the Mau Mau – were in revolt. Ngugi’s half-brother was a member, leading at one point to his mother being tortured.

It was to be another 10 years, however, before Ngugi’s politics got him into such trouble he was no longer able to remain in Kenya. The performance of his “radical” play was closed down after a few weeks, and at midnight, on December 30, 1977, the police arrived at his house, removed many of his books as evidence, and took him off for questioning. As he writes in Wrestling with the Devil, they told him he was not under arrest, but insisted he get into the car. His pregnant wife Njeeri watched, and only later did he realise she had known immediately it would be a long time before they saw each other again. “This was an abduction. Still, I couldn’t help musing over the fact that the police squadron was armed to the teeth to abduct a writer whose only acts of violent resistance were safely between the hard and soft covers of books.”

Without trial, he was thrown into prison. The first few weeks were awful, as he was kept in isolation. It confirmed what he had always feared: “Maximum security: the idea used to fill me with terror whenever I met it in fiction, Dickens mostly, and I have always associated it with England and Englishness; it conjured up images of hordes of dangerous killers a la Magwitch of Great Expectations, always ready to escape through thick forests and marshes, to unleash yet more havoc and terror on an otherwise stable, peaceful and God-fearing community of property owners that sees itself as the whole society.”

What Ngugi endured for the following 12 months was dreadful but he found courage in the friendship of his fellow political inmates. Above all, he kept sane by writing a novel on toilet paper, sheet by sheet, hiding the finished pages in the stack of unused sanitary paper. “The paper itself was not the soothing, softie-softie kind. It was actually hard, meant to punish prisoners, but it turned out to be great writing material”.

Wrestling with the Devil is in part his account of writing the novel that was to become Devil on a Cross, the first novel ever written in Gikuyu. He chose this language, he explains, “as a challenge to myself, a way of affirming my faith in the possibilities of the languages of all the different Kenyan nationalities, languages whose growth as vehicles for people’s struggles and development had been actively suppressed by the British colonial regime (1895-1963) and now its post-colonial successor”. Around the same time he changed his “colonial” name James Thiong’o Ngugi to his present name.

The emotional suffering he went through in that year is hard to imagine, yet for all its rage, Wrestling with the Devil is a remarkable account of his detainment. Most striking is that, while there is outrage and anger at the way he and others and their country were being treated, there is also a bigger philosophical vision, a sense that refusing to be completely cowed, and standing up to tyrants, be they prison guards or state leaders, is the only way to survive with dignity, and to help others improve their world.

Thanks in part to the outcry led by Amnesty International, Ngugi was freed, along with others, shortly after Kenyatta’s death. But he was not given his university job back, and so he and his family fled. It was to be many years before he felt able to return. When he did, in 2004, the apartment in which he and his wife were staying was broken into. While he fought off the men in one room, his wife was raped in another. The slow and deliberate way in which the attack and robbery took place led him to think the gang was carrying out orders. Thus, the sorrow and fear with which he left Kenya, were horrifyingly mirrored on his return.

Today, he and his wife live in California, but the list of essential books he recommended to the audience in Auckland is proof that his homeland is always in his mind. They are: Black Jacobins by C L R James, God’s Bits of Wood by Osemane Sembene, The Wretched of the Earth by Frantz Fanon, Half of a Yellow Sun by Ngozi Adichie, and his son Mukoma wa Ngugi’s novel, Nairobi Heat. Wrestling with the Devil is a new and edited edition of Detained: A Writer’s Prison Diary. It is published by Vintage, £8.99. Ngugi wa Thiong’o is speaking at the Edinburgh International Book Festival on August 11.