The retired detective ends up in Saughton prison while awaiting trial over a case dating back nearly 50 years, the writer has disclosed.
Speaking at the Edinburgh International Book Festival, Sir Ian read an extract from the book, which revealed Rebus’s daughter Samantha was looking after his dog Brillo while awaiting his fate.
The author also revealed the new book, published in October, will be set during a period of Covid restrictions in Edinburgh, drawing on his own inspirations of life in the city during lockdown.
The next Rebus book, A Heart Full of Headstones, is said to see the former detective on trial “for a crime that could put him behind bars for the rest of his life”.
Sir Ian also discussed his recent knighthood, the prospects of a 'young Rebus' novel and his hopes for Brian Cox to revive his role as Rebus for a new stage play he has written, after the Dundee-born Succession star played the character for a National Theatre of Scotland film made during lockdown.
Sir Ian, who described how he never plots out any of his novels in advance, admitted he could not recall what had inspired the premise behind the new Rebus book.
He said: “I don’t know exactly where this one came from. Often it is just something I have read in a newspaper or something somebody tells me in the pub, something from Edinburgh’s past, some criminal or an unsolved case that gets the motor going.
"I never think about plotting. When I start a book I have no idea where it is going to go. When I started this new one I had no idea.
"I can’t remember what got this book going. It was possibly the need to just write. Writing is a way of not having to think too hard about the mess the world is in.
"The one thing crime fiction does is to shape the chaos. For many of us right now it feels like we're living in very chaotic times. It may be a false pleasure that crime fiction gives because at end of the story it wraps things up quite neatly.”
Sir Ian read a tantalising page from the start of his new novel, describing how Rebus was spending “his first time in the dock” in court, with the jury absent due to the pandemic and watching proceedings in a cinema on Lothian Road. The extract revealed Rebus had first given evidence in the case, which has ended up with him going on trial nearly half a century ago.
Sir Ian read: “There was a simplicity to life in custody. Other people took decisions for you. He didn’t have to think about meals or dog walks or what he had to do with his day.
"Being an ex-cop, he even found himself popular with the prison guards. They liked to linger in his cell, sharing stories. They kept an eye open too. Not everyone inside would have his best interests at heart, which is why he had the luxury of unshared accommodation when HMP Edinburgh was bursting at the seams.
"Not that anyone outside of a few pen-pushers referred to it as HMP Edinburgh. It was Saughton.”
Sir Ian appeared to bring the Rebus series to an end in 2007, with the novel Exit Music, but brought the character out of retirement five years later to help with unsolved cases.
But the author said: “When the time came for him to retire as a detective I thought that was it. I didn’t think it was realistic for a civilian to be solving crimes.
“For four or five years I went off and did other things, but then learned that retired detectives sometimes work for the police on cold cases. It was exactly the job for Rebus. He would not want to shuffle off to be a taxi driver, open a bed and breakfast, or retire to Marbella.
"He came back for one book, but it was so energising for him to back in the room again and readers loved having him back again. I thought maybe there was more I could do with him.
"It gets progressively harder. The older he gets, the further away he gets away from the days when he actually was a serving detective.
“It presents me with challenges as to how to inveigle his way into a police inquiry, but it is also a lot of fun. He can’t get past the front door of a police station any more because he doesn’t have a warrant card.
"It’s fun for me to see challenges for him while also trying to keep it realistic that he could still at his age become involved in police inquiries.”
Another two new books in the series, which will be the the 24th and 25th, were confirmed earlier this year.
Sir Ian said: “The clock has been slowing somewhat of late. I made a mistake in the first book by making him around 40 years old. He is aging in reverse dog years now. One human year is only a few months of his life.
"I decided to set the new book towards the end of the Covid lockdowns, because that’s really when it was being written so it was nice and fresh in my memory.
"I had also had a little bit of fun when the National Theatre of Scotland asked me to do a piece that they could do online, which would comment on Covid and lockdown.
"People had been asking me on Twitter how Rebus would have coped with Covid and lockdown.
"I wrote monologue for Rebus and we got Brian Cox to do it remotely during lockdown from his cabin in New York State. It was extraordinary."