Prelude to Foundation is set in the year 12,020 G.E. (Galactic era), during the rocky reign of the Emperor Cleon I. It starts with Hari's presentation of a paper at a mathematics convention detailing how practical use of psychohistory might theoretically be possible. The Emperor of the Galactic Empire learns of this and wants to use Hari for political gain. But an interview with Hari causes Cleon to conclude that Hari is of no use to the Empire. After he leaves he goes to see the rest of Trantor.
Hari then meets reporter Chetter Hummin, who convinces him that Cleon's first minister, Eto Demerzel, is attempting to capture him, and that it is therefore imperative for Hari to escape and to try to make psychohistory practical. Thus, Hari accompanied by Hummin goes to Streeling University, one of the top ranked of the Empire, with the idea of developing a practical application to anticipate the future. He is introduced to Dors Venabili by Hummin. Hari theorizes that in order to make psychohistory work, he needs to find a small but significative sample, and that the best one would be the original world where humans originated...which is now lost to all but in a few histories.
Hari and Dors narrowly evade capture at Streeling University, following which the pair move to Mycogen. Hari and Dors are welcomed to Mycogen by Sunmaster Fourteen, the leader of Mycogen. Determined to work out his psychohistory with the knowledge that the Mycogenians supposedly possess, Hari decides to speak to a Mycogenian alone about history, hoping to find if their world was the original one as they claim. He manages this by convincing Raindrop Forty-Three to show him the prized Mycogenian microfarms, a prized source of food for the aristocracy and Mycogenians alike, then asking her to show her their religious historical book. Raindrop Forty-Three accepts on the condition that Hari allows her to touch his hair, hair being expressly forbidden in Mycogenian society. When Hari starts reading the book, he finds it disappointing except for the revelation of what the Mycogenians call their home planet, Aurora, and references to "robots".
Hari and Dors are almost killed when they try to find what they suspect is a robot in the Mycogenian "temple", called the Sacratorium, until Hummin arrives in the nick of time to save them. The action then shifts to the Dahl sector, where Dors displays her amazing knife-fighting skills. While in Dahl they meet a guttersnipe named Raych, whom Hari later adopts as his son. Also in Dahl, they are told by an old wise woman that the Aurora of the Mycogenians is not the original world, but actually the "enemy" that destroyed the original human planet, called Earth. (This links with the Robot series.)
Towards the end of the novel, Hari, Dors, and Raych are kidnapped by agents from Wye, a powerful sector situated at Trantor's south pole. There Hari has the revelation that he does not need the original planet, but that the best example to develop psychohistory would actually be Trantor itself, because of the great cultural diversity of its sectors. The finale reveals that "Hummin" is actually Cleon's first minister Eto Demerzel, who is later revealed to be, in reality, the robot R. Daneel Olivaw, who wants the development of psychohistory to help him protect humanity perpetually, as per "The Zeroth Law Of Robotics." By the end of the novel, Hari suspects that Dors is a robot, too. This theme would later be picked up in Forward the Foundation.