In the novel's opening, Andrew "Ender" Wiggin has a device removed from his neck which was used to monitor his thoughts and activities. No longer under Government surveillance, another boy, Stilson, attacks him.
Ender severely injures the boy, believing that this will prevent his friends from attempting to continue bullying him. Because of the logic behind his decisionmaking, he is selected for training at the elite Battle School. After some deliberation, Ender accepts out of a sense of duty and a desire to escape from the torment he suffers at the hands of his sociopathic older brother Peter.At Battle School, the commander Hyrum Graff publicly recognizes Ender as the most intelligent attendee. This acknowledgment causes other students to resent Ender, isolating him from most of the other children. Ender soon ranks among the school's elite child soldiers, eventually achieving the school's top rank.
Even after his success the other children continue to ostracize him. Ender attempts to escape his isolation and frustration in various ways, but experiences little comfort until he receives a letter from his older sister Valentine, reminding him of his reasons for attending Battle School in the first place.Meanwhile, Valentine and Peter form an uneasy alliance. Under the aliases of "Locke" and "Demosthenes", they publish scholarly essays advocating, respectively, diplomacy and all-out war with Russia. The end goal is to create a global emergency so that Peter can seize power.
Valentine, who sees Peter for who he truly is, is horrified at first, but relents when he unexpectedly reveals that he truly believes he can make the world a better place. Their writings find audiences at the highest levels of government, powerful people who (at first) have no idea they are reading the works of children.Graff eventually figures it out, however, and resolves to use Valentine as a tool to keep Ender under their control. The Battle School brass soon promote Ender to commander of a new army called "Dragon Army" in the school's zero-gravity wargame league.
He molds his young soldiers into an undefeated team, despite working with an inexperienced army. Ender's army implements innovative tactics, abolishing old methods like the use of formations in the battle room.Eventually the other commanders begin to resent him, and Ender is forced to defend himself from an assault by one particularly malicious commander, Bonzo Madrid, whom Ender unwittingly kills. At this point, it is revealed to the reader that Ender also killed Stilson, though Ender is unaware of the fact. The Battle School administration promotes Ender to Command School ahead of schedule.
In Command School, and under the tutelage of Mazer Rackham, the legendary hero of the Formic wars, Ender plays a game very similar to the Battle Room, where he commands ships in a 3-D space battle simulator.His subordinate officers are fellow students advanced early from the battle school who later become known as "Ender's jeesh". Each day the games become increasingly grueling, and Ender is slowly worn down to exhaustion. Waking and sleeping blend together as Ender nearly loses his mind, while still maintaining his military innovation and leadership. During his restless sleep he has recurring dreams of a fantasy game he played early in his training, as well as visions of the Buggers vivisecting him and removing his memories.Ender's "final exam" consists of a scenario where bugger ships outnumber Ender's fleet a thousand to one near a planetary mass.
Ender orders the use of a special weapon, the Molecular Disruption Device, against the planet itself, destroying the simulated planet and all ships in orbit. Ender makes this decision knowing that it is expressly against the respectable rules of the game, hoping that his teachers will find his ruthlessness unacceptable, remove him from command, and allow him to return home.Soon after Ender's destruction of the "simulated" Formic fleet, Rackham tells him that all the simulations were real battles taking place with real fleets, and that he had killed all the queens on their home planet. After Ender realizes that he is responsible for the destruction of an entire race, the guilt of the xenocide sends him into depressive sleep. He also learns at this point that he had previously killed two humans, Bonzo Madrid and Stilson, which only adds to his depression. When Ender recovers, his sister Valentine explains that war has broken out on Earth, and been resolved.
Ender will not be allowed to return to Earth because his special skills are too dangerous to fall under anyone's control, namely Peter. Ender is made Governor of the first human colony on a Bugger world, and they leave together on the first colony ship. While scouting out locations for future cities, Ender discovers a message from the Formics (expressed in the form of terrain matching that of the key fantasy game Ender played while in school) that leads him to an unborn Formic queen who can communicate with him through a psychic link.She explains that her race was initially unaware that human individuals were sentient creatures. The Formic defeat in the Second Invasion awakened them to humanity's true nature, and they resolved not to attack Earth again.
With direct communication impossible between the species, the only connection they were able make was with Ender's dreaming mind, but he did not know who was reaching out to him. Ender realizes that the Formics left one Queen behind for Ender to find.This was the purpose of their communications with him, through his dreams; the Queen was left behind for Ender to ultimately understand, forgive, and establish in a new home to re-populate the Formic population. Selectively withholding the fact that one 'Bugger' still lives, Ender writes a book in the Queen's voice under the pseudonym "Speaker for the Dead" entitled The Hive Queen, wherein he tells the story of the Formic race.Peter, now the Hegemon, also contacts Ender, claiming to know that Ender wrote it, and that he wishes for Ender to write a similar book, detailing Peter's life. The book is titled 'Hegemon'.
Publication of both books as "The Hive Queen and the Hegemon" results in the formation of a new religion on Earth and its colonies. In the end, Ender and Valentine board a starship and start visiting many worlds, looking for the right one for the unborn Queen.