Foundation's Edge, a science fiction novel and the sixth book in the Foundation series, tells the story of Golan Trevize and Janov Pelorat, who have been sent by the Mayor to discover the location of the Second Foundation. When they come across the planet Gaia, where every being is connected through a hive mind, they must make an important decision about humanity's future. Their choice is complicated by Harla Branno and Stor Gendibal, two people who have followed Trevize and Pelorat on their mission looking to use the pair's discoveries for their own purposes.
Five hundred years after the establishment of the Foundation, the Mayor of Terminus, Harla Branno, is basking in a political glow, her policies having been vindicated by the recent successful resolution of a Seldon Crisis. Golan Trevize, a former officer of the Navy and now a member of Council, believes the Second Foundation (which is almost universally thought to be extinct) still exists and is controlling events. He attempts to question the continued existence of the Seldon Plan during a Council session and Branno has him arrested on a charge of treason. She orders him to leave Terminus to search for the Second Foundation. As a cover, he is to be accompanied by Janov Pelorat, a professor of Ancient History and mythologist, who is interested in the location of Earth, the fabled homeworld of humanity. They are provided a highly advanced computer-controlled 'gravitic' ship with which to carry out their mission. Branno also sends out Munn Li Compor in another similar vessel to follow and monitor Trevize.
On Trantor, Stor Gendibal, a rising intellect in the Second Foundation hierarchy, discovers a secret he reveals to Quindor Shandess, the current First Speaker— that the Seldon Plan, which the Second Foundation diligently protects and furthers along, is being manipulated by some unknown group, one possibly more powerful than the Second Foundation, and whose reasons for so doing are not known. (This group is dubbed the "Anti-Mules" by Shandess, as they seem to possess powers similar to the Mule but to be using them not to destroy the Seldon Plan, as the Mule did, but to preserve it.) Gendibal concludes that Trevize is a "lightning rod" sent out to locate and expose the Second Foundation. His ideas are not well received by the other Speakers, but hehas the support of Shandess.
Trevize never intends to go to Trantor, believing that, once at the library, Pelorat will never leave. Trevize and Pelorat discuss Pelorat's interest in Earth and its legends, and Trevize realizes that Seldon's phrase "at the other end of the Galaxy" (the phrase he used to describe the Second Foundation's location) could mean Earth. His logic being that Terminus (at the time of Hari Seldon) was the last planet to be inhabited (one end of the metaphorical galaxy) and, by definition, Earth was the first (the other end of the metaphorical galaxy). However, there is no planet named Earth in the galactic table of planets. Pelorat, through his previous research, established characteristics that Earth must have: a 24-hour day, a 365-day year, and a large satellite. Once again no planet on file has these characteristics, but the galactic table of planets is missing a lot of information about a lot of planets. Nonetheless, Pelorat has a guess. The table mentions a planet called Gaia, which Pelorat discovered, previously, to mean Earth. Its exact coordinates are unknown but it is listed as being in the Sayshell Sector. Trevize decides that they must go to the Sayshell Sector to follow up on this lead.
Gendibal demonstrates to the Speaker's Table that the brain of Sura Novi, a Hamishwoman (the farming population of Trantor are known as the Hamish), shows a very subtle change in her mind that could only have been done by an agency more powerful than the Second Foundation. He believes it was done by the "Anti-Mules" and that they have a separate agenda with the Second Foundation as their unwitting pawn. Gendibal and Novi are sent to track Trevize and to determine the goals of the "Anti-Mules."
On Sayshell, Trevize and Pelorat meet Professor Quintesetz, who is able to give them the co-ordinates to the mysterious planet known as Gaia. Traveling to Gaia, they discover that it is a 'superorganism', where all things, both living and inanimate, participate in a larger, group consciousness, while still retaining any individual awareness they might have, such as among the Gaian humans. Pelorat slowly falls in love with a Gaian woman named Blissenobiarella (commonly called Bliss), who explains that Trevize will be forced to decide the future of the galaxy— whether it will be ruled by the First Foundation, the Second Foundation, or by Gaia (who envisions an eventual extension of its group consciousness to the entire galaxy, thus forming the new entity Galaxia ).
Gendibal is met by a First Foundation warship, commanded by Mayor Branno. As Gendibal's mental powers stalemate with Mayor Branno's force shield, Novi reveals herself as an agent of Gaia. Once she joins the stalemate, the three are locked until Trevize can join them.
Bliss explains to Trevize that he had been led to Gaia so that his untouched mind, a mind with remarkable intuition, can decide the Galaxy's fate. He also learns that the stalemate between the First Foundation (Branno), the Second Foundation (Gendibal), and Gaia (Novi) was intentional, and that through the ship's computer, he can decide who shall ultimately prove victorious.
Trevize decides upon Gaia, and through mental adjustments, Gaia makes Branno and Gendibal believe they have won minor victories, and that Gaia does not exist. But Trevize is troubled by one final piece of missing information: who or what has removed all reference to Earth from the Galactic Library at Trantor, and why . He announces his intention to find Earth, since without knowing the answers to those questions he cannot be certain his choice was the right one. Trevize also mentions that he chose Gaia because that was the only choice of the three that was reversible (in case his choice should prove to be wrong), due to the large length of time required for the formation of Galaxia.