Ember is a self-contained, self-maintained city. All food and supplies come from giant storerooms under the city and a handful of greenhouses. All the books in the library, apart from the city history "The Book of Ember" and the schoolbooks "The Book of Letters" and "The Book of Numbers", have been hand written by residents over the years of Ember. All the light in the city comes from lamps and floodlights; when these are extinguished, the city is completely dark, no stars, sun, or moon.

The electricity in the city comes from an ancient hydro-electric generator in the underground Pipeworks; keeping the aging generator operational is a constant task. Beyond the borders of Ember are the dark Unknown Regions, which are unexplorable because none of the citizens of Ember can produce a mobile source of light. Ember was constructed many years ago by the Builders, but nothing is known about them other than the fact that they built lots of stuff.

The story begins immediately after the construction of the city. Two of the Builders discuss what will happen when supplies run low and conditions become bleak, and decide to leave instructions for escape in a special sealed box, which will open automatically after 200 years, when it will be safe to leave the city. The box is entrusted to the Mayor of Ember, who passes it down to the following Mayor when he leaves office. While the Mayors do not know what the box contains, they keep it safe over the years and do not tell anyone about it. However, the box is lost and forgotten when the seventh Mayor unsuccessfully tries to open it (prematurely) and then dies before he can pass it on to the next Mayor.

The action then shifts to the year 241 in Ember. It is Assignment Day at the Ember school. On this day, the 12 year-olds finish their education and enter the workforce. They are assigned jobs at random by drawing pieces of paper from a bag held by the mayor. In room 8, one student, Lina Mayfleet, draws the job of Pipe-works Laborer; which will require her to work underground in the huge Pipeworks that power Ember and deliver its water, repairing lights and pipes as needed. Another student, Doon Harrow, becomes a Messenger. The Messengers are Ember's communication team, who run around the city relaying personal messages between citizens.

Both Lina and Doon dislike their chosen jobs, and therefore exchange them. Doon wishes to become an electrician because he is seriously concerned with the state of the city and the generator. Blackouts and power outages are becoming common in Ember. No one knows when the generator will stop. In addition, supplies are dwindling, buildings are crumbling and the city seems to be breaking down piece by piece. On the job in the Pipeworks, Doon explores the tunnels and tries to discover a way to save Ember. He even sneaks into the room containing the giant Generator, but realizes at once that he has no idea how it works, much less how to repair it.

Lina is thrilled to have the job of Messenger because it allows her to run and explore every corner of Ember while she delivers her messages. She works hard, puzzling over secret messages passed to the Mayor from a strange man named Looper. She also copes with her grandmother's ever failing health, and cares for her little sister, Poppy.

Poppy discovers an ancient piece of paper in a box in the Mayfleet apartment. By the time Lina manages to pry it out of the toddler's hands, the paper has been chewed and torn to pieces, and the writing has been obscured in many places. Lina hangs on to the scraps, and becomes convinced they hold a special message. She shows the paper to certain friends and neighbors, including her old classmate Lizzie Bisco, but nobody has any clues as to its significance.

Lina's grandmother cannot explain the paper either, but incoherently rambles on about finding "something that was lost". In the middle of one night, she calls Lina in. She mutters something about a baby, then falls asleep. That night, she dies. One of the Mayfleet family's neighbors, a kindly woman named Mrs. Murdo, offers to take Lina and Poppy in. Lina accepts this offer.

Eventually, and thanks to Clary, the greenhouse helper, Doon and Lina piece the paper together and a friend tells Lina that the message contains "Instructions for Egress"--instructions to leave Ember. They descend into the Pipeworks and discover that the instructions are indeed valid, and that the underground river holds the key to escape from the city. They also discover that a man named Looper is stealing the disappearing resources of Ember from the storerooms and giving them to the Mayor in a secret room in the Pipeworks. They report the Mayor's theft to City Hall, confident that he will be arrested.

However, the Mayor sets his guards upon the pair, and orders their arrest for "spreading vicious rumors." Before they can tell the residents of Ember about the Instructions for Egress, they are forced to flee the city. Lina manages to take her little sister Poppy, and, with Doon, goes down into the Pipeworks and flees Ember by boat on the underground river.

The river eventually leads to a great rock slope. Poppy discovers a book on the riverbank; Lina and Doon keep it and bring it along to read later. After a long and arduous climb, Lina, Doon and Poppy emerge from the rocks into a new world, where they discover sunlight, moonlight, stars and nature.

This discovery is followed by another one, their history. The battered book turns out to be a personal journal; reading it, Lina and Doon learn that their city was founded by a group of one hundred adults and the same number of children as a measure to guarantee the survival of the human race in a disaster that obliterated civilization.

Doon and Lina explore a nearby cave. Looking down from a high cliff in the cave, they are amazed to see Ember below them--and realize that they have been living underground all along. In a last-ditch effort to save their city's citizens, the three write a note with the Instructions for Egress, wrap it in Doon's shirt, and hurl it down into Ember where it is found by Mrs. Murdo.