Annemarie Johansen and her friend, Ellen Rosen, are ten-year-old girls living in Copenhagen, Denmark, during World War II. Annemarie has a 5-year-old sister named Kirsti. There are Nazis on every street corner in Copenhagen. Butter, sugar, coffee, cigarettes and other goods are unavailable. Electricity and many other things have been rationed.
After an encounter with two German soldiers, Annemarie and Ellen are much more careful. Later on, it turns out that for unknown reasons the Germans are "relocating" Denmark's Jews. At the synagogue, the Nazis have taken the names and addresses of all the Jewish people in Copenhagen. Ellen and her family are Jewish. Ellen's parents have fled with Peter, the former fiancé of Annemarie's older sister, Lise, who died years before. Ellen must stay with the Johansens, pretending to be Lise, even though she is half the age of the real Lise. Soldiers enter the Johansens' apartment at 4 in the morning, thinking that the Rosens are "Paying a visit" to the Johansens. Annemarie and Ellen wake up and Annemarie breaks the Star of David necklace off Ellen's neck. If the soldiers had seen it, they would have known Ellen was a Jew. The soldiers see Ellen's dark hair and become suspicious because the Johansens have blond hair, and Ellen has brown hair. Luckily, Lise had brown hair as an infant. Mr. Johansen shows the Nazis a picture of baby Lise, and they leave.
Mrs. Johansen, Annemarie, Ellen, and Kirsti leave the next morning to go to Uncle Henrik's house by the sea. Sweden, a Nazi-free country, can be seen from Uncle Henrik's house. Before they had gone to his house, Mr. Johansen had spoken in code to Henrik. When they get there, Henrik seems like his ordinary self. The next day, Henrik says that Annemarie's Great-Aunt Birte has died. A huge casket is placed in the middle of the living room. Annemarie knows that there is no Aunt Birte, but learns from her uncle that it is easier to be brave if you do not know something, so she does not tell Ellen the truth about her "aunt".
Later on, many people come to mourn "Aunt Birte", to Annemarie's puzzlement. Nazis come to the house and see all the people and start questioning the family. They explain that Great-Aunt Birte has died, and they are carrying out traditional rituals. The Nazis order the casket opened, and Mrs. Johansen acts fast. She says that Great-Aunt Birte had typhus, a very contagious and dangerous disease, or so the doctor said. She goes to the casket to open it, but one of the soldiers slaps her in the face and says they can open it when the soldiers leave.
After they leave, the wake continues. Peter, who is present, reads the beginning of Psalm 147 from the Bible to the group, recounting the Lord God numbering the stars. As the psalm is not familiar to Annemarie, her thoughts begin to wander. She wonders how it is possible to number the stars in the sky and remembers Ellen saying that her mother is afraid of the ocean because her mother thinks it is cold and cruel. Annemarie thinks that the night sky and the world are also cold and cruel. Peter opens the casket and gives the warm clothing and blankets concealed within it to the Jewish families. They depart in smaller groups to avoid attracting attention. Ellen says goodbye to Annemarie and her mother.
In the morning, Annemarie sees her mother crawling in the distance because she had broken her ankle. After helping her mother back to the house, Annemarie finds a packet of great importance to the Resistance, a packet which Mr. Rosen dropped when he accidentally tripped on a flight of stairs. Mrs. Johansen tells Annemarie to fill a basket with food and the packet, and run as fast as she can. Annemarie runs off onto a wooded path in the direction of her uncle's boat. She is halted by Nazi soldiers with dogs. When they question Annemarie about what she is doing out so early, she lies, saying that she is taking a basket with a meal to her uncle. The soldiers do not believe her, and one of them grabs at the basket. However, the soldiers eventually let her go, and Annemarie makes it to her uncle's boat. She gives Uncle Henrik an envelope that contains a handkerchief. The handkerchief had traces of cocaine on it to numb the dog's sense of smell. When the Nazi dogs took onto the boat sniff the handkerchief, they can no longer smell Uncle Henrik's hidden "cargo": the Jewish people he is smuggling to safety.
Uncle Henrik returns to Denmark later that evening from Sweden. He tells Annemarie that many Jewish people, including the Rosens, were hiding in his boat. He also explains that the handkerchief in her package contained the scent of rabbit blood, which attracted the dogs, and the strong odor of cocaine, which numbs their noses, preventing them from tracking down the Jews in Henrik's boat. Several revelations are made, including that Peter is in the Danish Resistance.
Two years later, the war in Europe ends, and all of Denmark celebrates. The Jews who were forced to leave Denmark will find that their friends and neighbors have kept up their apartments in hopes of their return. Peter had been captured and executed by the Nazis in the town square earlier in the war, after which Annemarie learned that her sister Lise died, not in an accident, but because the Nazis intentionally hit her with a military car: she was also in the Resistance. It is unknown whether Ellen or her parents return to Copenhagen.