Doctor Eggman kidnaps Princess Elise of Soleanna in the hopes of harnessing the Flames of Disaster, a destructive power sealed within her. Aided by his friends Tails and Knuckles, Sonic works to protect Elise from Eggman. Meanwhile, Shadow and his fellow agent Rouge accidentally release an evil spirit, Mephiles. The spirit transports them to a post-apocalyptic future ravaged by a demonic monster, Iblis. When Mephiles meets survivors Silver and Blaze, he fools them into thinking Sonic is the cause of this destruction and sends them to the present to kill him.
Throughout the story, Sonic and friends travel between the past, present, and future in their efforts to stop Mephiles and Iblis and protect Elise from Doctor Eggman. Though at first Silver stalks Sonic and impedes his attempts to save Elise, Shadow reveals to him that Sonic is not the cause of his world's suffering but rather Mephiles, who is trying to change the past for his own evil purposes. They learn that Mephiles seeks to bond with Iblis, who was sealed within Elise as a child, as they are the two halves of Soleanna's omnipotent god, Solaris. Mephiles eventually succeeds after killing Sonic to make Elise cry over his death, releasing her seal on Iblis and merging with him to become Solaris, who then attempts to consume time itself. The heroes use the power of the Chaos Emeralds to revive Sonic, and he, Shadow, and Silver transform into their super forms to defeat Solaris. Sonic and Elise are brought to the past and extinguish Solaris's flame, removing the god from existence and preventing the previous events from ever occurring. Despite this, Sonic and Elise show faint of recalling their encounter afterwards.