Mary Shelley wrote Frankenstein as part of a friendly competition among a group of friends, which included her husband Percy Bysshe Shelley and the poet Lord Byron, to see who could write the best ghost story. The idea for Frankenstein came to Mary in a dream, and she began to write the novel as a short story before expanding it into a full-length novel.