One of the events in Ray Bradbury's childhood that inspired him to become a writer was an encounter with a carnival magician named Mr. Electrico who commanded him to "Live forever!" The 12-year-old Bradbury, intrigued at the concept of eternal life, revisited Mr. Electrico, who spurred his passion for life by heralding him as the reincarnation of a friend lost in World War I. After that memorable day, Bradbury began writing nonstop.
The novel originated in 1955 when Bradbury suggested to his friend Gene Kelly that they collaborate on a movie for Kelly to direct. Kelly was encouraging of the idea, and Bradbury spent the next five weeks adapting his 1948 short story "The Black Ferris" into an 80-page treatment. Kelly shopped the project to various studios, but was unable to obtain financial backing for the movie. Bradbury then gradually expanded the treatment into the novel over a five-year period. He converted the benign presence of Mr. Electrico into a more sinister one and incorporated several members he met at the same carnival with Mr. Electrico, including the Illustrated Man and the Skeleton Man.
The book's autumnal setting was intended as a thematic sequel to Bradbury's summer-tinged Dandelion Wine. Both works are set in the fictitious Green Town (based on Bradbury's hometown, Waukegan, Illinois) but have different tones, with the seasons in which they are set reflecting different aspects of the transition from childhood to adulthood. While none of the characters in Dandelion Wine reappear in Something Wicked This Way Comes, Will Halloway and Jim Nightshade can be viewed as one-year older representations of Dandelion Wine's Douglas Spaulding and John Huff, respectively. These two novels, coupled with Bradbury's official 2006 sequel to Dandelion Wine, Farewell Summer, constitute what Bradbury has termed his "Green Town Trilogy." The 2008 short story collection Summer Morning, Summer Night is also set in Green Town.
The novel's title was taken directly from a line in Act IV of William Shakespeare's Macbeth: "By the pricking of my thumbs / Something wicked this way comes."