Raskolnikov confesses because he can no longer bear being alone with the crime and with the theory that failed: when he tells Sonia the truth, he says he went to her for one thing only, "so that you won't leave me," and only after Porfiry accuses him without proof and Sonia points him toward the way does he speak at the police station.
The first confession is to Sonia, in Part Five. He arrives still excited by his victory over Luzhin, recounts the event in the third person, offers reasons and disowns each one, and concludes: "Was it the old woman I killed? It was myself I killed, and not the old woman!" Soon after, back in his room, the narrator says he had never felt "so terribly alone."
Sonia asks him for a public rite: kiss the earth, bow down to the world, and say aloud that he killed. He refuses and says he will fight. In Part Six, Porfiry offers him a voluntary surrender with a reduced sentence, and he answers: "I don't want your reduction at all!" Shortly before giving himself up, he tells his sister that he killed "a filthy, harmful louse" and adds: "I don't think about it and I don't think about washing it off."
On his last visit to Sonia, he understands that what he went to get was her weeping: "I needed her tears." He kisses the earth in the square because he remembers the order she gave him, and he says the phrase at the police station only after hearing that Svidrigailov has killed himself. The motives remain open. In the Epilogue, tormented by the question of why he did not kill himself on the riverbank, he explains it by a dull instinct, and the narrator suggests another cause: a premonition, already there, of the falsity of his convictions. The text supports both readings: the shame of having failed, or the first sign of change.