Dostoyevsky conceived the idea of Crime and Punishment in the summer of 1865, having gambled away much of his fortune, unable to pay his bills or afford proper meals. At the time the author owed large sums of money to creditors, and was trying to help the family of his brother Mikhail, who had died in early 1864. Projected under the title The Drunkards, it was to deal "with the present question of drunkness ... [in] all its ramifications, especially the picture of a family and the bringing up of children in these circumstance, etc., etc." Once Dostoyevsky conceived Raskolnikov and his crime, now inspired by the case of Pierre François Lacenaire, this theme became ancillary, centering on the story of the Marmeladov family.
Dostoyevsky offered his story or novella (at the time Dostoyevsky was not thinking of a novel) to the publisher Mikhail Katkov, whose monthly journal, The Russian Messenger, was a prestigious publication of its kind, and the outlet for both Ivan Turgenev and Leo Tolstoy. However, Dostoyevsky, having carried on quite bruising polemics with Katkov in early 1860s, had never published anything in its pages. Nonetheless, forced by his situation, after all other appeals elsewhere failed, Dostoyevsky turned as a last resort to Katkov, urging for an advance on a proposed contribution. In a letter to Katkov written in September 1865, Dostoyevsky explained to him that the work was to be about a young man who yields to "certain strange, 'unfinished' ideas, yet floating in the air"; he had thus embarked on his plan to explore the moral and psychological dangers of the ideology of "radicalism". In letters written in November 1865 an important conceptual change occurred: the "story" has become a "novel", and from here on all references to Crime and Punishment are to a novel.
Dostoyevsky had to race against time, in order to finish on time both The Gambler and Crime and Punishment. Anna Snitkina, a stenographer who would soon become his second wife, was a great help for Dostoyevsky during this difficult task. The first part of Crime and Punishment appeared in the January 1866 issue of The Russian Messenger, and the last one was published in December 1866.
At the end of November much had been written and was ready; I burned it all; I can confess that now. I didn't like it myself. A new form, a new plan excited me, and I started all over again.— Dostoyevsky's letter to his friend Alexander Wrangel in February 1866
In the complete edition of Dostoyevsky's writings published in the Soviet Union, the editors reassembled and printed the notebooks that the writer kept while working on Crime and Punishment, in a sequence roughly corresponding to the various stages of composition. Because of these labors, there is now a fragmentary working draft of the story, or novella, as initially conceived, as well as two other versions of the text. These have been distinguished as the Wiesbaden edition, the Petersburg edition, and the final plan, involving the shift from a first-person narrator to the indigenous variety of third-person form invented by Dostoyevsky. The Wiesbaden edition concentrates entirely on the moral/physic reactions of the narrator after the murder. It coincides roughly with the story that Dostoyevsky described in his letter to Katkov, and written in a form of a diary or journal, corresponds to what eventually became part II.
I wrote [this chapter] with genuine inspiration, but perhaps it is no good; but for them the question is not its literary worth, they are worried about its morality. Here I was in the right—nothing was against morality, and even quite the contrary, but they saw otherwise and, what's more, saw traces of nihilism ... I took it back, and this revision of a large chapter cost me at least three new chapters of work, judging by the effort and the weariness; but I corrected it and gave it back.— Dostoyevsky's letter to A.P. Milyukov
Why Dostoyevsky abandoned his initial version remains a matter of speculation. According to Joseph Frank, "one possibility is that his protagonist began to develop beyond the boundaries in which he had first been conceived". The notebooks indicate that Dostoyevsky was aware of the emergence of new aspects of Raskolnikov's character as the plot action proceeded, and he structured the novel in conformity with this "metamorphosis," Frank says. Dostoyevsky thus decided to fuse the story with his previous idea for a novel called The Drunkards. The final version of Crime and Punishment came into being only when, in November 1865, Dostoyevsky decided to recast his novel in the third person. This shift was the culmination of a long struggle, present through all the early stages of composition. Once having decided, Dostoyevsky began to rewrite from scratch, and was able to easily integrate sections of the early manuscript into the final text—Frank says that he did not, as he told Wrangel, burn everything he had written earlier.
The final draft went smoothly, except for a clash with the editors of The Russian Messenger, about which very little is known. Since the manuscript Dostoyevsky turned in to Katkov was lost, it is unclear to what the editors had objected in the original.