Nabokov began to compose Despair while he was living in Berlin beginning in July 1932 and managed to complete the first draft on September 10 of the same year. The year in which Nabokov was writing Despair was a turbulent one for Germany. In June 1932, the Reichstag had collapsed and Incumbent President President Paul von Hindenburg called for elections, leading to violence between the Nazis and Communists. It would not be long before the Nazi party would come into prominence and Hitler appointed as chancellor. This would only fuel Nabokov's hatred for totalitarian governments, and this disdain was incorporated somewhat into Despair (Hermann is pro-Communist) and more prominently later on in Invitation to a Beheading (1936), Nabokov's next novel.
In 1935, Nabokov began to become increasingly intrigued with the English language and elected to translate his two most recently written novels at the time, Laughter in the Dark (1932) (first translated as Camera Obscura) and Despair. Nabokov remarked that translating Despair was his "first serious attempt... to use English for what may loosely termed an artistic purpose" and finished on December 29 later that year. Nabokov sent the manuscript to Hutchinson & Co. in April 1936 and although the company had initial reservations, eventually agreed to publish the book and the translation was checked by a Molly Carpenter-Lee, a student of Nabokov's friend Gleb Struve. The book was a complete flop commercially and Nabokov only earned €40, a minuscule amount, even in the 1930s. The issue was that Hutchinson's only published cheap, "popular" novels, which Despair was not and thus, it was distributed to the wrong audience. Nabokov would later lament that Despair was "a rhinoceros in a world of hummingbirds".
Nabokov intended Hermann, and the novel in general, to be kind of a Dostoevskian (who is referred to as "Dusky and Dusty" in the novel) parody; this is even more evident as the original working title for the novel was to be Zapiski mistifikatora (Notes of a Hoaxer), akin to Dostoevsky's Notes from Underground. At one particular, Hermann even contemplates titling his narrative The Double, before he realizes it has been used, and opts for Despair instead. Nabokov infamously despised Dostoevsky's writing, with its excessive soul-searching and glorification of criminals and prostitutes and this is reflected in Despair and Hermann, who carries certain similarities to Raskolnikov, who had also planned a perfect murder in Crime and Punishment. Additionally, the book is rich in intertextual connections to other authors such as Pushkin, Gogol, Turgenev, Oscar Wilde, and Conan Doyle.