The author of the best-selling graphic novel says his mother’s death when he was 19 may have led him to think of his most famous character.
Speaking to BBC News Scotland, Sir Iain Rankin revealed that just two weeks after he left his home in Fife to study at the University of Edinburgh, his mother Isabel fell ill.
She died just 10 months later, never receiving a formal diagnosis.
“It was a difficult time and the stuff I wrote became very dark as a result, and maybe that was the beginning of my journey into writing dark police novels about Edinburgh,” he says.
When his mother fell ill, Sir Ian was forced to divide his time between his home town and his new life in Edinburgh, “pretending to be a bohemian” by his own admission.
“I would smoke Gauloises and recite crappy poetry that I had written, and then I would jump on the train and go back to Cadenden and watch my mum go from bad to worse,” he said.
His writing helped him process her death.
“When something like this happens, you feel like humanity seems a little dim, and you wonder, where is God in all of this, nowhere to be seen,” he said.
“[With crime fiction] You’re looking at the human condition and you’re trying to answer some really big questions about how the world is and how humans are, so my mom’s death probably got me thinking about those questions.
The father-of-two remembers his mother growing up in Bradford as a “lovely little mum” who worked in the school canteen and later a chicken factory.
“She was a fantastic cook, a true Yorkshire cook. She made the best pith puddings in the oven. She made the best Yorkshire puddings,” he said.
Ten years later, his father, Jim, died. He saw his son become a published author, but he did not live long enough to see him become the best-selling author he is today.
The Edinburgh author, 64, whose John Rebus series has sold more than 35 million copies, is about to release his 25th book, Midnight and Blue.
But he has no plans to retire.
He uses his writing to make sense of the world, and when things go well, “it’s really fun.”
WARNING: The next section contains spoilers for Iain Rankin’s new novel
He gets excited when he has a great idea, and then he wants people to read it.
But the self-described perfectionist said the idea then “started to slip away from him” and he had to write another book.
However, he does consider his latest book, Midnight and Blue, in which Rebus is convicted and sent to Thornton Prison, to be one of his best books to date.
He had thought his last Rebus novel, A Heart Full of Tombstones, would be the last because it ended with a “lovely cliffhanger” as the former detective was about to be sentenced.
But his fans disagreed and said they needed to know what happened next.
“So it dawned on me that a former detective at Edinburgh Prison, also known as Saughton Prison, was surrounded by people who hated him because he was a former police officer,” he said.
As part of his research, he spent a day in a real-life prison.
His drawing series has been translated into 36 languages, and he was knighted for services to literature and charity.
“I’m living the dream, but that doesn’t make it any easier to write the book,” he said.
“I have the impression that it gets easier the more you write, but it seems to get harder as you get older.”
However, Sir Ian has never had a problem with motivation, which he attributes to his working-class background.
“I wanted to prove to the world that even though I didn’t come from a good background, I was good at something,” he said.
Now that he’s proven himself, it makes him “feel great,” he added.
But he bristles at the prospect of people being able to use artificial intelligence to write books for them.
“The computer can’t write it, it just steals it from other people. It scans all the available texts and uses them to transcribe the story,” he said.
“It’s a mash-up of other people’s ideas.”
Sir Ian has read an “Ian Rankin-style” book on artificial intelligence but said it was “rubbish”.
“I think humans are the most extraordinary creation, and having artificial intelligence do everything for us will make us less extraordinary,” he said.
So what’s left for Sir Ian, who still enjoys a weekly drink at Edinburgh’s Oxford Pub?
“I won’t give up drinking, I think it’s delicious,” he said.
Instead, he hopes to one day get on former President Obama’s reading list, which could boost the author’s visibility and sales.
“I hope Barack Obama reads my book,” he said. “That’s how to hack America, but I’ve had no luck with it so far.”