Force to be reckoned with … Ian Rankin brought Rebus back last year in Standing in Another Man’s Grave. Photograph: David Fisher/Rex Features

Grayson Perry's recent description of his position in the art world as a maverick mascot – "the dirty teddy you see tied to the front of the radiator on a refuse truck" – could, nowadays, be equally well applied to Rankin's John Rebus in relation to the fictional Scottish police force. By my reckoning, the dishevelled old bear – still drinking, still smoking, still listening to those LPs alone in his flat and chippier than ever – is now 66 years old. Rankin officially retired Rebus from the force in his 2007 novel Exit Music, but brought him back last year in Standing in Another Man's Grave, a decision that did not seem particularly surprising in view of the fact that the author's new central character, Malcolm Fox of "Complaints" (the police internal affairs department) is, although potentially more complex and nuanced than Rebus, definitely lacking in the older man's immediate and highly flavoured appeal.

Standing in Another Man's Grave had Rebus working for the serious crime review unit in a civilian capacity and travelling all over Scotland, but, for his 19th outing, he is back in Edinburgh, where he – and his creator – are at their best and most assured. He's also back in the CID, retirement age for detectives having been raised, but he has been demoted to detective sergeant and is reporting to his former protegee Siobhan Clarke. They are investigating a mysterious car accident involving a Volkswagen Golf, a tree and Jessica, the daughter of powerful businessman Owen Traynor. Jessica is the girlfriend of the justice minister's son, and nobody is forthcoming about the driver of the smashed car, who appears to have legged it. Rebus's attempts to assert his authority go unheeded. "My town, my rules," he calls rather pathetically after Owen, who is in any case from Croydon, and ignores him.

Rebus is reporting to Malcolm Fox, too, and looking into a 30-year-old murder case that fell apart in court and is now being reopened after changes to the law on double jeopardy. The two men have an uneasy relationship because Rebus was investigated by Fox when he was attempting to rejoin the force. Fox being a reformed alcoholic doesn't do much to ease the strain, either, and neither does the fact that the coppers they are investigating are Rebus's old colleagues, who appear to have organised things so that one of their informants was able to walk away from a murder charge. The group, rule‑benders and corner-cutters to a man, called themselves "the Saints" and swore an oath of allegiance on a book they called the "Shadow Bible". Now, with the exception of Rebus, they are no longer members of the police force, but they still regard their invented freemasonry as an unbreakable bond. Rebus, whose own cupboards are not without the odd skeleton, finds himself caught in the middle.

Fox himself is facing an uncertain future – this is his last case before he rejoins the CID, where he will be in the unenviable position of working alongside some of the men and women he has investigated over the years. Rebus's position, as ever, is one of subversive compliance, and, although he and Fox don't become bosom pals, they do manage enough of an alliance for a mutual scramble across the thin ice of uncertain knowledge and moral relativity to a resolution.

Rebus: Saint or Sinner? says the marketing slogan, but Saints of the Shadow Bible is much more subtle, and ambitious, than this binary opposition suggests. Set against the campaigns in the runup to the referendum on Scottish independence, it is a fascinating exploration of ideas of loyalty and allegiance in a changing world, as well as a welcome return for a battered but tenacious survivor.