The story follows two brothers, Junpei Senou and Kanta Senou, who live on the island of Shikotan with their grandfather, a fisherman, and their father, Tatsuo, who is the head of the village’s firefighting force. Their peaceful life is disrupted after Japan's defeat in World War II and the subsequent invasion of the islands by the Soviet Red Army. As a result, the family is forced to leave their home and relocate to the stables, while the Russian commander's family, including the commander's daughter Tanya, moves into the main house.
During this period of upheaval, the island becomes divided: Russian children now share the school with Japanese students, and eventually, Tanya and her friends begin to socialize with the Japanese children during recess. A developing friendship forms between Tanya and the brothers after a playful incident on the playground where Junpei bumps into her, which leads to an invitation for the brothers to visit Tanya's home for dinner. The story deepens as the brothers' uncle, Hideo, asks Junpei to light signal fires at night to help him make covert trips to the main island for essential supplies, despite the danger involved.
Meanwhile, their father Tatsuo, with the assistance of their teacher, Sawako, Yukie Nakama, secretly retrieves food from the Dawn Corps' emergency stocks and supplies it to their village. However, when Hideo attempts to smuggle this food for profit, he is caught, leading Tatsuo to be arrested after rushing to the cave where the supplies are stored.
The narrative accelerates to the harrowing day of September 25, 1947, when Japanese residents are ordered to assemble at the harbor to be transported back to the mainland. Junpei, Kanta, and Sawako board the ship, while their grandfather chooses to stay behind, determined to spend his last moments at sea. Upon arrival at an internment camp in Maoka, the family learns that Tatsuo is alive but held at another camp nearby. Driven by hope, Kanta, mistakenly interpreting Hideo's news literally, sets out to find their father, aided by Junpei. Sawako and Hideo follow to help, and they all together visit Tatsuo's camp, where they share emotional farewells. Tatsuo promises to find a way to reunite with them.
Tragedy strikes when Kanta falls gravely ill during their attempt to return, and despite efforts to save him, he passes away en route. Junpei and Sawako eventually reunite with Hideo at the harbor, where Junpei tries to fool the guards into thinking Kanta is alive by recounting the story of the "Night on the Galactic Railroad," a story he often shared with Kanta. During this moment, Junpei experiences a vision of Kanta's spirit riding a ghostly train into the stars, symbolizing his brother's peaceful farewell.
Decades later, Junpei and Sawako return to Shikotan to pay respects at the graves of Tatsuo and Kanta. They attend a graduation ceremony for those who missed it in childhood, and Junpei receives a notebook containing a sketch of Tanya’s granddaughter, a reminder of the enduring connections formed through their shared history. Junpei also exchanges his copy of the Night on the Galactic Railroad with the girl, mourning Tanya’s passing a year prior.
The gathering concludes with Russian and Japanese residents dancing together, celebrating their intertwined past and shared hope. Tanya’s granddaughter invites Junpei to dance, and as they do, the scene transforms into a mesmerizing display of spirits—original residents of Shikotan—dancing among the stars, symbolizing the enduring spirit of their community and the timeless nature of memory and connection.