"
From Wikipedia Foundation series

Prelude to Foundation

Prelude to Foundation opens on the planet Trantor, the empire's capital planet, the day after Hari Seldon has given a speech at a conference. Several parties become aware of the content of his speech (that using mathematical formulas, it may be possible to predict the future course of human history). Seldon is hounded by the Emperor and various employed thugs who are working surreptitiously, which forces him into exile. Over the course of the book, Seldon and Dors Venabili, a female companion, are taken from location to location by an aide, Chetter Hummin, who introduces them to various walks of life in his attempts to keep Seldon hidden from the Emperor. Throughout their adventures all over Trantor, Seldon continuously denies that psychohistory is a realistic science. Even if feasible, it may take several decades to develop. Hummin, however, is convinced that Seldon knows something, so he continuously presses him to work out a starting point to develop psychohistory. Eventually, after much traveling and introductions to various, diverse cultures on Trantor, Seldon realizes that using the entire known galaxy as a starting point is too overwhelming, then decides to use Trantor as a model to work out the science, with a goal of using the applied knowledge on the rest of the galaxy.

Forward the Foundation

Main article: Forward the Foundation Eight years after the events of Prelude, Seldon has worked out the science of psychohistory and has applied it on a galactic scale. His notability and fame increase and he is eventually promoted to First Minister to the Emperor. As the book progresses, Seldon loses those closest to him, including his wife, Dors Venabili, as his own health deteriorates into old age. Having worked his entire adult life to understand psychohistory, Seldon instructs his granddaughter, Wanda, to set up the Second Foundation.

Foundation

Called forth to stand trial on Trantor for allegations of treason (for foreshadowing the decline of the Galactic Empire), Seldon explains that his science of psychohistory foresees many alternatives, all of which result in the Galactic Empire eventually falling. If humanity follows its current path, the Empire will fall and 30,000 years of turmoil will overcome humanity before a second Empire arises. However, an alternative path allows for the intervening years to be only one thousand, if Seldon is allowed to collect the most intelligent minds and create a compendium of all human knowledge, entitled Encyclopedia Galactica. The board is still wary but allows Seldon to assemble whomever he needs, provided he and the "Encyclopedists" be exiled to a remote planet, Terminus. Seldon agrees to set up his own collection of Encyclopedists, and also secretly implements a contingency plan—a second Foundation—at the "opposite end" of the galaxy. Once on Terminus, the inhabitants find themselves at a loss. With four powerful planets surrounding their own, the Encyclopedists have no defenses but their own intelligence. The Mayor of Terminus City, Salvor Hardin, proposes to play the planets against each other. His plan is a success; the Foundation remains untouched, and he is promoted to Mayor of Terminus (the planet). Meanwhile, the minds of the Foundation continue to develop newer and greater technologies which are smaller and more powerful than the Empire's equivalents. Using its scientific advantage, Terminus develops trade routes with nearby planets, eventually taking them over when its technology becomes a much-needed commodity. The interplanetary traders effectively become the new diplomats to other planets. One such trader, Hober Mallow, becomes powerful enough to challenge and win the seat of Mayor and, by cutting off supplies to a nearby region, also succeeds in adding more planets to the Foundation's reach.

Foundation and Empire

The current Emperor of the Galaxy perceives the Foundation as a growing threat and orders an attack on it, using the Empire's still-mighty fleet of war vessels. However, eventually convinced, as foretold by psychohistory, that his power would be most vulnerable to that of his own successful general (a possible analogy with that of the Roman empire at various times), the Emperor finally orders withdrawal of his fleet. In spite of its undoubted inferiority in purely military terms, the Foundation emerges as the victor and the Empire itself is defeated. Meanwhile, an unknown outsider known as the Mule has begun taking over planets belonging to the Foundation at a rapid pace. When the Foundation comes to realize the Mule was not foreseen in Seldon's plan, and there is no predicted way of defeating him, Toran and Bayta Darell, accompanied by Ebling Mis—the galaxy's current greatest psychologist—and a court jester named Magnifico (whom they agree to protect, as his life is under threat from the Mule himself), set out to find the Second Foundation, hoping they bring an end to the Mule's reign. Eventually, working in the still-functional Great Library of Trantor, Mis comes to learn of the Second Foundation's whereabouts. Mis also deduces that the Mule's success stems from his mutation; he is able to change the emotions of others, a power he used to first instill fear in the inhabitants of his conquered planets, then to make his enemies devoutly loyal to him. Having worked out that the Mule is also attempting to find the location of the Second Foundation, Bayta Darell kills Mis before he can reveal where the Second Foundation is. Bayta explains that she regrets her actions, but that the secret had to be kept from the Mule at all costs. Magnifico reveals that Bayta's suspicions about him are correct and that he is the Mule and has been laboring to find the Second Foundation in order to start his own Second Empire, hundreds of years before the Seldon Plan is to be complete. Dismayed at having made a mistake which allowed Bayta to see through his disguise, he leaves Trantor to rule over his conquered planets while continuing his own search.