The Magic Lamp is an object that appears in Sonic and the Secret Rings. It is an oil lamp from the world of the Arabian Nights that was used to imprison Erazor Djinn in ancient times until he had granted the wishes of a thousand people as punishment for his evil. It can also be used to force Erazor Djinn to grant three wishes to the person who wields it.
Long ago, the Erazor Djinn was sealed inside the Magic Lamp as punishment for his crimes until he had granted the wishes of a thousand people. After serving his sentence, Erazor was free to continue his evil ways, though he was still bound to the Magic Lamp and its hold over him. Under unknown circumstances, the Magic Lamp was crushed into a twisted orb and came into the possession of Shahra.
When Sonic the Hedgehog found the Blue World Ring, Shahra gave the crushed Magic Lamp to Sonic, only telling him it would be their last resort for stopping Erazor as she could not use it herself. When Shahra was killed by Erazor, Sonic wished to Shahra that she would "go back to the way she was", which led to the Magic Lamp being restored. After Sonic beat Erazor, he understood the meaning behind the lamp and how to use it against Erazor.
Despite Erazor's refusal, Sonic used the Magic Lamp's power over Erazor to make him grant three wishes: bring Shahra back to life, restore the world of the Arabian Nights and its storybook back to normal, and trap Erazor himself within the Magic Lamp until the end of time. After granting the final wish, Erazor was sucked into the Magic Lamp, sealing him within it once more. Sonic then took the Magic Lamp to the Evil Foundry and threw it into the lava pools in hopes that no one would ever find it again.
Other game appearances
During the "Desert Ruins" event, the Magic Lamps are one of the many treasures sought by treasure hunters. During one of their treasure hunts, Team Sonic acquire one from a sealed treasure chamber.