The story picks up from the ending of Sonic 3 - Dr. Robotnik's orbital weapon, the Death Egg, has been badly damaged in the climactic battle between himself and Sonic The Hedgehog. As the satellite falls back to the Floating Island, landing in a volcanic crater, Sonic jumps off, landing in a mushroom filled woodland.
Sonic knows there are many Chaos Emeralds hidden on the island, including the powerful Super Emeralds and the Master Emerald, the secret to the island's levitation powers. Worried that Robotnik may try to harness this power to fuel a repaired Death Egg, he sets off to try and destroy the Death Egg once and for all, keeping an eye out for Knuckles the Echidna, still smarting from his Launch Base defeat.
At Hidden Palace, Sonic finds Knuckles there waiting for him. They fight and Sonic seems to emerge victorious when Knuckles flees from the duel after sensing someone is trying to steal the Master Emerald. Knuckles races ahead closely followed by Sonic to find Robotnik trying to steal the Master Emerald: It had been his plan all along to snatch it while Sonic and Knuckles were too busy dealing with each other. Realizing he had been tricked, Knuckles reacts by attacking Robotnik, which fails when Robotnik electrocutes Knuckles. Sonic tries to intervene but Robotnik stills manages to escape. Knuckles now realizes his mistake and that Sonic is in fact on his side. They join forces and teleport to Sky Sanctuary.
At Sky Sanctuary, Knuckles and Sonic watch the Death Egg launching in the background. Knuckles activates a bridge so Sonic can cross over. Sonic defeats a rebuilt Metal Sonic on the way to the Death Egg, and manages to board it before it leaves the atmosphere. Onboard the Death Egg, Sonic defeats Robotnik and destroys the ship once and for all, only for Robotnik to get away with the Master Emerald in one of his giant robots. If Sonic hasn't collected all seven Chaos Emeralds and/or Super Emeralds, the game ends here, and the ending in which the Master Emerald does not return to Angel Island occurs. After the credits, the player sees a scene with Robotnik still in possession of the Master Emerald.
If all the seven Chaos Emeralds and/or Super Emeralds are collected, Sonic transforms into Super Sonic or Hyper Sonic and chases Robotnik into the Doomsday Zone. After failing to lose him in an asteroid belt, Robotnik's machine is destroyed, Sonic and Tails return the Master Emerald, and the Floating Island becomes airborne once again. If the player didn't collect all the Super Emeralds, a scene occurs which shows an Egg Robo emerging from a pile of metal. If all Emeralds are collected, the player sees the Sonic 3 and Knuckles logo featuring Sonic, Tails, and Knuckles.