In The Dark Remains, Rankin has completed the last unfinished novel by William McIlvanney who died in 2015 only two years after the republication of his Laidlaw detective series, which had been out of print for many years.
Rankin became involved in the project after McIlvanney's widow, Siobhan Lynch, found around 100 pages of handwritten notes and contacted publishing house Canongate, who asked him to see if they had the makings of a book.
She asked if he would take on the project of completing the novel from the notes, which included a title, structure, some chapters pretty much fully written, and some character details.
Edinburgh crime: Man critical after suffering serious head injury in city centre ‘fight’
Edinburgh weather: Here is when the storm is set to hit the Capital and the Lothians today
A71 crash: Edinburgh commuters face delays after ‘serious’ two-vehicle crash at Dalmahoy Junction
Edinburgh news: Emergency services called to street in Capital after bin lorry hits block of flats
Edinburgh weather: Capital and the Lothians warned as Met Office predict thunderstorms to follow heat wave
Rankin said he hesitated over whether to take on the challenge because he was not sure if he could do it justice, but decided to do so to help honour McIlvanney's legacy.
He told the PA news agency: "I'm a huge fan of William McIlvanney and I don't want him to be forgotten about again, he was sort of forgotten about previously and then had this wonderful renaissance late on in his in life where he was discovered by readers and publishers so I wanted to keep his memory alive, keep his books in print and also it was a challenge.
"I'd never written a book for anyone else before, I'd certainly never written a book set in Glasgow before and I've never written a book set in 1972.
"So there was challenge, there was the fact I wanted to try and honour William McIlvanney's legacy and I wanted to bring him some new readers."
While working on the book Rankin re-read the Laidlaw novels, first published between 1977 and 1991, to help him capture McIlvanney's voice, and went to the National Library of Scotland in Edinburgh where he pored over copies of the Glasgow Herald from 1972 to see what was happening in the wider world and check details such as the price of a suit and what people were watching on television.
The writer, creator of Detective Inspector Rebus, said he has been delighted by the reaction from readers who have said they are now going to read the other Laidlaw books.
He said: "That's exactly what I wanted, for readers to not only read this but to go off and explore the rest of William McIlvanney's universe."
Rankin, who will discuss The Dark Remains at the Bloody Scotland festival in Stirling at 7pm on Friday, also enjoyed writing the book as it helped him forget about the pandemic while immersed in the Glasgow of 1972, where Laidlaw is investigating the murder of a shady lawyer.
He said: "During the pandemic and lockdown I've written a lot more than I normally write partly because I'm not travelling, I'm not touring, I'm not doing festivals around the world, and partly because it is an escape from the pandemic to write fiction, and, especially in the case of The Dark Remains, it was lovely to go back in time to a much simpler world."
The Edinburgh-based writer said that he is in "no hurry" to write about the pandemic though will in future have to think about how it factors in.
He has written a Rebus stage play about a murder at an Edinburgh dinner party which is now with a producer and will hopefully be seen on stages around the UK next year.
And his thoughts are now turning to his next book which is likely to see the return of DI Rebus.
He said: "I think it's going to be a Rebus book. There's a little bit of unfinished business at the end of A Song for the Dark Times and I want to clear that up, people keep asking me what happens at the end, you left it very open and just for my own peace of mind I want to clear that up which means writing another book."
The winner of the McIlvanney Prize, Bloody Scotland's annual prize awarded to the best Scottish Crime book of the year, will also be announced on Friday September 17.