In a future where aliens have attacked Earth twice, the government recruits children and trains them to fight in what they believe will be the third and final war with the aliens. The aliens are called "Buggers," due to their ant-like appearance and hive-like behavior.
Six-year-old Andrew "Ender" Wiggin is monitored by the government through a device attached to his neck, to see if he is a good candidate for Battle School. Other children do not like Ender because he is a prodigy, and he is also the third child in a society that has limited families to two children.
The government eventually removes the monitoring device but still watches Ender to see how he will handle not having their protection. Soon after the device is removed, Ender is bullied by the other children and attacked by a boy named Stilson. Ender believes that the only way to permanently stop Stilson and his friends from harassing him is to fight, win the fight and severely injure Stilson in the process, which Ender does. Because of this reasoning, Ender is approached by the Battle School director, Colonel Hyrum Graff, and asked to attend the school, which is located in a vessel that orbits Earth.
Even though he knows he will not see his family for several years, Ender accepts the mission out of a sense of duty. He also does not want to face the other children at his school and wants to get away from his sadistic older brother, Peter.
At Battle School, Colonel Graff publicly identifies Ender as the smartest and most promising student, causing the other boys to resent and alienate him. While Ender excels at his studies and training, he becomes depressed, and the leaders of the Battle School become concerned about his mental health. Graff returns to Earth and contacts Ender's beloved older sister, Valentine, and asks her to write Ender an encouraging letter. This is the first and only letter that Ender has been allowed to receive.
Back on Earth, Valentine misses Ender terribly and is afraid of her brother Peter, who she knows has been torturing and killing small animals in the woods. Peter approaches her and asks her to help him write and publish political essays on the Net (the book's version of the Internet). Valentine recognizes that he is manipulating her to help him gain political power, but she agrees. They use the pseudonyms of "Locke" for Peter and "Demosthenes" for Valentine.
After the Bugger War ends, the children post their writings that are both against and for a war with Russia on political forums. Like Ender, Peter and Valentine are prodigies. After a while, their essays receive worldwide attention. Colonel Graff eventually discovers the real identities of Locke and Demosthenes. Using this information against her, he gets Valentine to keep Ender under control.
Ender's emotional state improves. At age 9, he is promoted to command the Dragon Army in the Battle School's fighting league. Ender trains his young and inexperienced soldiers into formidable fighters; he implements innovative techniques and unique tactics. Dragon Army goes undefeated, much to the anger of the other student army leaders, especially Bonzo Madrid, one of Ender's former commanders, who has a grudge against him.
Bonzo attacks Ender. Similar to the fight with Stilson, Ender beats Bonzo into unconsciousness. After the fight, Ender quickly graduates and is promoted to Command School, skipping Pre-Command School altogether. Unknown to Ender, he killed both Stilson and Bonzo in those fights.
Command School is located on the planet Eros, and Ender's instructor turns out to be Mazer Rackham, the legendary commanding officer who led Earth to victory in the Bugger War.
Graff and Rackham explain to Ender that instead of waiting for the Buggers to attack, Earth has sent warships to the Bugger's home world. They are training Ender to command the fleet. When Ender wants to know why Rackham does not command the fleet himself, Rackham tells Ender that he must be in command because he is faster, a better fighter and less cautious than Rackham.
Ender begins training on a new battle simulator where instead of commanding ships, he now commands an entire fleet. His squadron leaders turn out to be the best students from Battle School, most of them Ender's friends. He works with them in the simulator and never sees them in person.
The isolation and grueling training takes its toll on Ender, who starts having dreams of Buggers cutting his body open and viewing his memories like holographs. Sleeping, waking, days, nights and battles start blending together for him, and he thinks he is going crazy. Ender stops eating. Even though he passes out in the training room, he gets no rest and is still forced to fight one simulated battle after another.
On his last day of Command School, Ender fights one last battle to determine whether he graduates. When the program starts, there is a planet in the simulation, and the enemy outnumbers Ender's ships 1,000 to one. Frustrated that he is given an impossible scenario that will result in him failing the test and afraid that everything he has gone through has been for nothing, Ender decides to break the rules of combat.
After briefly battling the Bugger ships, Ender orders his fleet to get close to the planet's atmosphere and aim their main weapon, the Molecular Detachment Device, at the planet. Ender does this knowing that destroying the planet is against the rules of engagement and hopes he will get kicked out of Command School so he can return home.
In the simulation, the device destroys the planet, most of the enemy ships protecting it and some of Ender's fleet that were within range of the explosion. After the battle, Ender is confused because there is a celebration in the room, and no one is angry with him for his actions. Only then does Rackham tell Ender that the simulations in Command School were actual battles with the Buggers, and that he just led Earth's fleet to victory against the Bugger army.
Realizing he caused the destruction of a planet, the genocide of an entire species and the death of numerous pilots in Earth's fleet, Ender becomes despondent and falls into a deep, depressive sleep.
Now that the Buggers have been destroyed, a league war, instigated by years of political essays by Locke and Demosthenes, breaks out on Earth and at command headquarters on Eros. A treaty proposed by Peter under the alias of Locke quickly ends the war. Though he is still a teenager, Peter gains incredible political power, and his age ceases to become a concern. Many people, not knowing the real Peter, view him as a great architect of peace.
Ender comes out of his depressive sleep state only after his friends and the squadron leaders he commands visit him. They tell him about the league war. Ender views video recordings of Graff's courtroom trial, where Graff is acquitted of war crimes against the Buggers. While watching the videos, Ender learns that Bonzo and Stilson both died from the injuries that Ender inflicted on them. Ender waits on Eros to see if he can return home to Earth. The deaths of Bonzo and Stilson weigh heavily on him.
Valentine travels to Eros and tells Ender that he can never return to Earth, as he would be under Peter's control. She asks that he go with her to colonize an abandoned Bugger planet, instead. Ender agrees, becoming the governor of the first human colony in space.
While scouting the planet, Ender discovers an area, constructed by the Buggers, that replicates scenes from a key fantasy game he played during Battle School. Ender explores the area and finds a pupa of a Bugger queen, who communicates with him through a psychic connection. Ender realizes the dreams he had during Command School were from the Buggers trying to communicate with him.
With images, the queen tells Ender that the Buggers thought they were the only thinking beings in the universe, and when they understood that humans were sentient, they did not return to Earth. She asks Ender to help find her a place nearby to hatch, but he refuses, knowing that other humans would kill her. He vows to find a planet where she can hatch in safety and give birth to her children. He also tells her that he will tell her story so that humans can learn to forgive her species the same way Buggers forgave him for killing them.
Without revealing that there is still a living Bugger queen, Ender, under the pseudonym of "Speaker for the Dead," writes the hive-queen's story. It includes the history of the Buggers, and the fact that they did not mean to hurt humans. Peter, now Hegemon (a political leader of Earth), reads the story and recognizes Ender's writing. He asks Ender to write a similar book for him, detailing his life. Together, the books are called Hive-Queen and Hegemon, and their popularity spurs a sort of religion—with fans wishing that when they die, someone would detail their own lives in the same way.
Ender and Valentine board a starship and go from world to world, looking for a place where the hive-queen can awaken and thrive in peace.