As Sonic celebrates his birthday with his friends, a mysterious being known as the Time Eater suddenly appears, destroying the party and sucking everyone through various "time holes", scattering them across different places in history. Sonic tries to stop him, but the monster easily knocks him out. After regaining consciousness, Sonic finds himself in a strange dimension known as 'White Space', a realm where time and space ends up after it has been 'erased' by being drained of color and life. Sonic rescues Tails and as they search for their friends, they encounter their younger selves, Classic Sonic, along with a younger Classic Tails. As the two Tails determine that Time Eater's actions are damaging time and space itself, both Classic and Modern Sonic race through their history, restoring time to normal and rescuing their friends.

After restoring the worlds and collecting all the Chaos Emeralds, they discover that the mastermind behind the now perfected Time Eater is none other than Dr. Eggman and his classic self. It is revealed that while drifting through space following the events of Sonic Colors, Eggman discovered the Time Eater and decided to join forces with his past self to harness its power, complete the Time Eater robot and erase his past defeats from history. Although the Time Eater manages to overwhelm the two Sonics, the support of their friends and the power of the Chaos Emeralds allow them to transform into their Super forms and defeat both versions of Eggman. With the Time Eater destroyed, time and space is restored and the group returns to the present and finally finishes celebrating Sonic's birthday. After the party, Classic Sonic and Classic Tails travel back to their time as everyone says their farewells. Meanwhile, Dr. Eggman and his classic self are lost in White Space.