The show takes place on a planet called Mobius. A warlord and former scientist named Dr. Robotnik, and his assistant/nephew Snively, invaded and conquered Mobotropolis, the capital city of Mobius, with an army of robot soldiers called SWATbots.
The show's backstory explains that Robotnik had once been leader of the Mobotropolis War Ministry, and that his creation and use of SWATbots led the country's victory in "The Great War". In the war's aftermath, he was to be appointed Minister of Science by the King of Mobius, who had decided to close the War Ministry and dismantle the SWATbots following the War. However, Robotnik overthrew the kingdom and declared himself to be the new King. King Acorn was never seen or heard from again.
Robotnik captures most of the citizens, including an intelligent old hedgehog named Sir Charles Hedgehog (Sonic's uncle) and his crowning invention, the Roboticizer. This invention, created with the intention to prolong life, changes living creatures into robots, but had the unintended effect of robbing the individual of their free will. Robotnik uses this technology to enslave the population.
Some citizens managed to escape the coup, and fled to Knothole Village in the Great Forest to hide from Robotnik's army. Under Princess Sally, they formed a group called the Freedom Fighters to restore Mobius and end Robotnik's rule.