In the future, the world has been twice attacked by aliens called Buggers, and humanity almost perished. To prepare for the next battle, the world unites around the cause of collecting and training military geniuses from early childhood. their one goal in life is to be the leaders of the army that defends Earth from the "Third Invasion."
Ender is one of those children. Andrew Wiggin's very birth was government-mandated - most families are allowed only two children, but the government requisitioned his birth. After a short six years of torment from his genius older brother Peter, and love from his genius older sister Valentine, Ender is recruited into the army after passing tests, and quickly rises to the top of the talent pool. Loved or hated by other students at Battle School, Ender is isolated by excellence in the games that the students play, and by the teachers' treatment of his excellence. The adults do not give him the chance to settle in and find a peer group - they push him with such urgency that they are willing to break the entire Battle School system down.
Colonel Graff, the one who found and groomed Ender, runs Battle School and risks his reputation, and humanity's existence, on his vehement belief that Ender is the one who can defeat the Buggers.
Battle School consists of games - there is a Fantasy Game, a game room (like an arcade), and the battleroom, where war games are played in zero gravity. The battleroom plays a central role in Battle School, and students often get so caught up in the game that they seldom realize that they're at the school to defeat the Buggers. One such student, Bonzo Madrid, comes to hate Ender, and Bonzo plans to kill him. Ender's excellence shines through in battle after battle, despite being given a green army and the most intense schedule ever given an army. Bonzo's rage turns murderous, and they fight in the showers. Once again, Ender's penchant for breaking the rules to win, and win completely, leads him to kill Bonzo in self-defense.
Ender's only respite in life is the thought of Valentine, his compassionate older sister, who defended Ender against the vicious Peter. However, on Earth, Valentine and Peter are now working together to use their collective genius and drive world affairs. Peter does this with the dream of world domination in mind, and Valentine does this reluctantly, as more of a game that she can play to keep her excellent mind busy. As Locke and Demosthenes, respectively, Peter and Valentine quickly become influential, despite being barely pubescent.
Ender's success at Battle School reaches a point where he must be promoted and leave his few trusted friends, Petra, Dink, Alai, and Bean, behind. He goes to Command School and finds only more games waiting for him. These games are intensely strategic, and Ender once again masters them. He also discovers that the "Third Invasion" is not Buggers attacking humans, but vice versa.
At this point, he meets Mazer Rackham, hero from the previous war, and trains under Mazer. Ender is reunited - albeit over a headset - with his friends, who serve as some of his squadron leaders. They train together and enter the most intense training scenario of their lives-an invasion scenario run by Mazer. The scenario strains all of them, ender most of all, who is nearly driven insane. At the final test, Ender faces the biggest lopsided scenario of all and decides to cheat, to give up. In so doing, he actually destroys the simulated enemy, which turns out to be the real enemy all along - the Buggers. Ender is distraught, and refuses a military life for himself.
Meanwhile, Peter reaches his goal and is named leader of the world. Valentine rejoins Ender, and the two go to a new Earth colony world where Ender discovers the egg of one single Bugger queen (which can spawn a whole new race of Buggers). It is his chance at redemption and he writes a short text from her perspective which becomes highly influential. In the end, Ender chooses an itinerant life, trying to speak for the dead, and trying to find a suitable place where Buggers can flourish once again.