Written from 17 March to 9 April 1941 and sold on 24 April, the short story was published in the September 1941 issue of Astounding Science Fiction under editor John W. Campbell. It was the 32nd story by Asimov, written while he was a graduate student in chemistry at Columbia University. Campbell asked Asimov to write the story after discussing with him a quotation from Ralph Waldo Emerson:
If the stars should appear one night in a thousand years, how would men believe and adore, and preserve for many generations the remembrance of the city of God!
Campbell's opinion was to the contrary: "I think men would go mad". He and Asimov chose the title "Nightfall" together. At more than 13,000 words it was Asimov's longest story yet, and including a bonus from Campbell he received US$166 (1 1⁄4 cents per word), more than twice any previous payment for a story. His name appeared on the cover of Astounding for the first time, and the story made Asimov—who later said that before "Nightfall" neither he nor anyone else other than perhaps Campbell considered him more than a "third rater"—one of the industry's top writers. Asimov believed that the unusual plot of "Nightfall" distinguished it from others, but "The Last Question" was his own favorite story.
In 1988, Martin H. Greenberg suggested Asimov find someone who would take his 47-year-old short story and – keeping the story essentially as written – add a detailed beginning and a detailed ending to it. This resulted in the 1990 publication of the novel Nightfall by Isaac Asimov and Robert Silverberg. As Asimov relates in the Robert Silverberg chapter of his autobiography, "...Eventually, I received the extended Nightfall manuscript from Bob [Silverberg]... Bob did a wonderful job and I could almost believe I had written the whole thing myself. He remained absolutely faithful to the original story and I had very little to argue with."