In a Central Park ant colony, Z-4195, or “Z” for short, is a neurotic and pessimistic worker ant who longs to express himself. His friends include fellow worker Azteca and a soldier ant, Weaver. Princess Bala uses a bar to escape her suffocating royal life, and Z falls in love with her there. To see Bala again, Z exchanges places with Weaver and joins the army, where he befriends Barbatus, a staff sergeant. Z is unaware the army’s leader and Bala’s fiancé General Mandible is secretly sending the soldiers loyal to the Queen Ant to die so he can build a powerful ant colony.
At the base of a tree near nightfall, Z realizes he is marching into battle; everyone except Z is killed by acid-shooting termites. Before dying, Barbatus tells Z to think for himself instead of following orders. Z returns home and is hailed as a war hero (despite not doing anything; left traumatized by the fighting). Secretly irate, Mandible congratulates him and introduces him to the Queen Ant. There he meets Bala, who eventually recognizes him as a worker. Finding that he has been cornered, Z panics and pretends to take Bala hostage, causing him and Bala to fall out the anthill via garbage chute. After escaping from a magnifying glass, Z searches for Insectopia, a legendary insect paradise. After arguing, Bala attempts to return to the colony but quickly rejoins Z after encountering a praying mantis.
News of the incident spreads through the colony, and Z’s act of individuality inspires the workers and some soldier ants, halting productivity. To gain control, Mandible publicly portrays Z as a self-centered war criminal. Mandible promotes the glory of conformity and promises them a better life through the reward of completing a “Mega Tunnel” planned by himself. However, Colonel Cutter, Mandible’s second-in-command, becomes concerned about Mandible’s plans.