At the beginning of Shadow the Hedgehog, which takes place three months after the events of Sonic Heroes, Shadow, still suffering from amnesia, remembers only two things: his name and "that gruesome image" of his attempt to escape the space station ARK with Gerald Robotnik's granddaughter Maria and her death by gunshot from G.U.N. soldiers. He wonders whether he is an android due to hints given in Sonic Heroes. The game begins with Shadow reminiscing outside the city of Westopolis when the Black Arms drop out of the sky and invade it. Doom's Eye approaches Shadow, and Black Doom tells Shadow of an old agreement for Shadow to bring him the Chaos Emeralds. Stunned that Black Doom knew his name, Shadow realizes that he must find the Chaos Emeralds to learn his past.
The game progresses through the Westopolis level and five more levels from the different paths Shadow can take. As missions are completed, Shadow learns more of his past. He can choose to help the Black Arms or Doctor Eggman (Dark), to help G.U.N. and the series' heroic characters (Hero), or to help neither and keep the Chaos Emeralds for himself (Neutral). The missions completed determine which one of ten possible endings will be seen after Shadow collects all the Chaos Emeralds and defeats one of the game's final bosses. The possible ending events range from planning to defeat the Black Arms to planning to destroy the planet.
Completing all ten endings unlocks a final ending in which Black Doom uses Chaos Control, enhanced by the power of all seven Chaos Emeralds, to bring the Black Comet to Earth. Shadow then confronts Black Doom on the "Last Way" level, where he discovers that Professor Gerald Robotnik created the ARK's Eclipse Cannon weapon to destroy the Black Comet. During their confrontation, Black Doom attempts to control Shadow through mind control but fails, prompting him to transform into his "Devil Doom" form. In response, Shadow uses the Chaos Emeralds to transform into his "Super Shadow" form and defeats Black Doom. Shadow then transports the Black Comet into outer space using Chaos Control and obliterates it with the ARK's Eclipse Cannon. His friends are elated, as are people at G.U.N. headquarters. Shadow is then shown in the ARK's control room holding up a photograph of Maria and Gerald. He discards the photograph, declaring "Goodbye forever... Shadow the Hedgehog," and leaves the room.