The locked-room mystery is a subgenre of detective fiction in which a crime—almost always murder—is committed under circumstances under which it was seemingly impossible for the perpetrator to commit the crime and/or evade detection in the course of getting in and out of the crime scene. The crime in question typically involves a crime scene with no indication as to how the intruder could have entered or left, i.e., a locked room. Following other conventions of classic detective fiction, the reader is normally presented with the puzzle and all of the clues, and is encouraged to solve the mystery before the solution is revealed in a dramatic climax.
To investigators of the crime, the prima facie impression almost invariably is that the perpetrator has vanished into thin air. The need for a rational explanation for the crime is what drives the protagonist to look beyond these appearances and solve the puzzle.
Though the mystery or detective genre was not established until the 19th century, there are notable predecessors in ancient writings. The deuterocanonical Old Testament story "Bel and the Dragon" has some similarities to locked-room mysteries; the hero Daniel debunks the worship of an idol that supposedly eats food offerings left for it in a sealed room, by exposing the secret entrance used by the priests who take the food for themselves. In the 5th century BC, Herodotus told the tale of the robber whose headless body was found in a sealed stone chamber with only one guarded exit. Honoré de Balzac in La Comedie Humaine (1799–1850): Maitre Cornelius (1846) and Alexandre Dumas, père in Les Mohicans de Paris: La Visite Domiciliaire (1854) included locked-room elements in their novels.
The earliest fully-fledged example of this type of story is generally held to be Edgar Allan Poe's "The Murders in the Rue Morgue" (1841). Wilkie Collins' The Moonstone (1868) features a rudimentary locked-room murder. A number of authors, including Joseph Conrad, Sheridan Le Fanu, and Dick Donovan, tried their hand at the new genre, but their ingenuity extended only to secret passages, duplicate keys, and diabolical mechanical devices. It was not until publication of Israel Zangwill's work The Big Bow Mystery (1892) that the hallmark of every great impossible crime—misdirection—made its appearance, introducing a murder technique much emulated since. The other great early work, Le Mystère de la Chambre Jaune (The Mystery of the Yellow Room), was written in 1907 by French journalist and author Gaston Leroux; it, too, has had many imitators.