The story begins with Tetsuya Ishigami and Yasuko Hanaoka following their daily routines. Yasuko Hanaoka is a divorced single mother who works at a bento shop. Ishigami is a highly talented mathematics teacher, who lives next door to Yasuko and her daughter Misato. When Togashi shows up one day to extort money from Yasuko, threatening both her and Misato, the situation quickly escalates into violence, and Togashi is killed by mother and daughter. Overhearing the commotion, Ishigami, who is secretly enamored of Yasuko but has never told her so, offers his help, disposing of the body and plotting the cover-up of the murder step-by-step. When the body turns up and is identified, Kusanagi draws the case and Yasuko comes under suspicion. Kusanagi is unable to find any obvious holes in Yasuko's manufactured alibi, but still he is sure that there's something wrong with her story, a suspicion that he cannot shake. Kusanagi brings in Dr. Manabu Yukawa, a physicist and his college friend who frequently consults with the police. Yukawa also went to college with Ishigami, where he learned of Ishigami's problem-solving techniques and abilities; Yukawa highly rates Ishigami's intelligence. After meeting him again after so many years, Yukawa becomes convinced that Ishigami had something to do with the murder. What ensues is a high-level battle of wits between Yukawa and Ishigami, as Ishigami tries to protect Yasuko by outmaneuvering and outthinking Yukawa; the teacher is Yukawa's most clever and determined opponent yet. Towards the end of the book, both Ishigami's scheme and the reason for his devotion to Yasuko are revealed: Ishigami had lost his will to live due to his depression, and was prepared to commit suicide when he was interrupted by Yasuko and Misato introducing themselves, leading him to become deeply attached to her and thankful for her unknowingly saving his life. In order to deceive the investigation, Ishigami murdered a second person, a homeless man who he had seen prior on his commute to work, and made the police believe he was Togashi, in order to obfuscate the time of the murder and make it so that in the end he could take the fall. Yukawa is ultimately able to figure out his scheme and cannot accept his friend's sacrifice, and so he tells Yasuko the truth. She is deeply moved and despite Ishigami's instructions to move forward, is unable to live with the guilt. The book ends with her meeting Ishigami in jail, revealing that she and Misato have confessed to killing Togashi and are determined to serve their sentence together with him, leaving him in tears.
It was also adapted into a 2019 Tamil movie titled Kolaigaran.
The 2013 Indian Malayalam film Drishyam is said to be inspired by The Devotion of Suspect X. Ekta Kapoor, who had purchased the Hindi film rights of the novel, sent a legal notice to the makers of Drishyam.
A Chinese film adaptation, The Devotion of Suspect X was released in 2017. The film was directed by Alec Su, and featured Ruby Lin and Wang Kai.