This article considers the history of the nightmare and argues that the nineteenth century in France sees a particular efflorescence of discursive attempts, across medical and literary fields, to explain, classify, and describe experientially this phenomenological concept. The article begins with a brief pan-European prehistory of the modern notion of the 'cauchemar' that explores its demonological and medical origins and the sexual connotations presumed to underlie it. Then, theories and representations of the nightmare in nineteenth-century French alienism and the literary genre of the conte fantastique (1820-40) are examined. It is argued that specific nineteenth-century preoccupations with rationality, and the subject's potential for alienation from it, which are heavily bound up with gendered discourses and values, make the nightmare (as an exemplary experience of loss of control) a topic of fascination for physicians, writers, and thinkers. I examine the extent to which the loss of mastery experienced in the nightmare, perceived with anxiety in medical writings, becomes, in contes fantastiques, especially those by Théophile Gautier, a transgressive experiment with the erotic experience of liberation from expectations of socially and sexually agentic masculinity. In this way the article offers both an original interpretation of the genre of the French fantastic, and a brief cultural genealogy of a phenomenon that has a long history in demonology and medicine, drawing particular attention to its specifically French nineteenth-century dimensions.