The Murders in the Rue Morgue
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). Robert Adey credits Sheridan Le Fanu for "A Passage in the Secret History of an Irish Countess" which was published three years before Poe's “Rue Morgue”.