The original trilogy of novels were originally a series of eight short stories published in Astounding Magazine between May 1942 and January 1950. According to Asimov, the premise was based on ideas set forth in Edward Gibbon's History of the Decline and Fall of the Roman Empire, and was invented spontaneously on his way to meet with editor John W. Campbell, with whom he developed the concepts of the collapse of the Galactic Empire, the civilization-preserving Foundations, and psychohistory. Asimov wrote these early stories in his West Philadelphia apartment when he worked at the Philadelphia Naval Yard.
The first four stories were collected, along with a new story taking place before the others, as a fixup published by Gnome Press in 1951 as Foundation. The remainder of the stories were published in pairs by Gnome as Foundation and Empire (1952) and Second Foundation (1953), resulting in the "Foundation Trilogy", as the series is still known.
Later sequels and prequels
In 1981, Asimov was persuaded by his publishers to write a fourth book, which became Foundation's Edge (1982).
Four years later, Asimov followed up with yet another sequel, Foundation and Earth (1986), which was followed by the prequels Prelude to Foundation (1988) and Forward the Foundation (1993), published after his death in 1992. During the two-year lapse between writing the sequels and prequels, Asimov had tied in his Foundation series with his various other series, creating a single unified universe. The basic link is mentioned in Foundation's Edge: an obscure tradition about a first wave of space settlements with robots and then a second without. The idea is the one developed in Robots of Dawn, which, in addition to showing the way that the second wave of settlements were to be allowed, illustrates the benefits and shortcomings of the first wave of settlements and their so-called C/Fe (carbon/iron, signifying humans and robots together) culture. In this same book, the word psychohistory is used to describe the nascent idea of Seldon's work. Some of the drawbacks to this style of colonization, also called Spacer culture, are also exemplified by the events described in The Naked Sun.