Meanwhile in the palace, Daisy and Robert were in a huge cage while Amy sat next to Khalid sadly.
"My dear Amy, it pains me to see you reduced to this. A beautiful rose such as yourself should be on the arm of the most powerful man in the world like me. You will make a wonderful queen for me." Khalid smirked as he cupped her chin.
"No way!" yelled Amy as she turned away angrily.
Khalid was angry at her rejection but then he got an idea.
"Genie, I have decided to make my final wish. I wish for princess Amy Rose to fall in love with me!" Khalid smirked as he winked at Amy which grossed her out.
"I'm sorry, master! It's against the rules!" Tails replied.
"Don't you talk back to me, you two-Tails mutt! You will do what I order you to do, slave!" Khalid snarled.
When Amy saw Sonic, Chip and the Carpet were sneaking inside the throneroom. Sonic silently hushed and Amy had an idea.
"Khalid, I had no idea how incrediby handsome you are!" Amy said seducively pretended to be in love with him which made Tails lose his jaw.
"That's better. Now, my little pumpkin!" Khalid smiled as he didn't realise that Amy tricked him into thinking his wish was granted. "Tell me more about myself."
"Well, you're tall.. Well dressed.." said Amy.
While Amy distracted Khalid, Sonic was sneaking to get the lamp.
"Continue, my dear!" Khalid said.
"And you're so strong and muscular." said Amy.
Then, Khalid saw the reflection of Sonic in Amy's forehead jewel. He turned around and used his powers to zap Sonic away from the lamp.
"You! How many times do I have to kill you, boy!" Khalid snarled and Amy pounched on him but he pushed her aside when he realised that Amy tricked him by pretending to be in love.
"Get the lamp!" Sonic said as he pounced on Khalid and they fought each other.
Amy was heading towards the lamp but Khalid used his magic to create a giant hourglass to trap Amy inside.
"Princess Amy, your time is up!" Khalid laughed evilly
"Amy!" Sonic cried as the sand was beginning to drop on Amy.
Chip and the carpet were about to get near the lamp, Khalid used his magic to turn Chip into a plush doll while turned the carpet into a yarnball.
Now it was just Sonic alone to fight against Khalid.
"Are you afraid to fight me, Khalid, you big coward?!" asked Sonic as he was ready to fight.
"A big coward, am I?" Khalid smiled wickedly. "Perhaps I'll show you, the BIG coward I am alright!!"
Khalid grew bigger and bigger and he his arms and clothes disappeared. Khalid used his fangs to bite Sonic but he dodged as he used his spin dash to hit Khalid. It was a real battle, but when he saw the sand continued to keep dropping on Amy that she almost couldn't breathe, Sonic rushed off with a sword to break Amy free.
"Amy, hang on!" Sonic cried when he was about to break her free but Khalid used his coils to wrap Sonic.
"You foolish little hedgehog! You think can defeat the most powerful sorcerer in the world? Well, you're wrong!" Khalid laughed wickedly, "Without the genie, you're nothing!"
When Sonic looked at Tails, he had an idea.
"Tails has more power than you’ll ever have!" Sonic smirked
"What!?" Khalid snapped
"That's right!He gave you your power, he can take it away!" Sonic said with a cocky smile which made Tails shocked to hear how Sonic brought him up with the confrontation.
"You're right! Your genie friend's power does exceed my own!" said Khalid, never though of it but then he smiled evilly as he slithered towards Tails. "But not for long!"
"I think Sonic must have gone crazy!" stuttered Tails nervously.
"Slave, my third wish! I wish to be the all-powerful genie!" Khalid demanded.
"Fine. Your wish is my command!" sighed Tails and then he turned to Sonic disappointedly. "Way to go, Sonic!"
Tails granted Khalid's wish and turned him into a genie. He still has his muscular cobrabody with arms which let Sonic go and the blue Hedgehog rushed into the hourglass with was completely full, he smashed the glass and set Amy free who was unconscious as Khalid went up to the sky with a triumph. Then a blue lamp appeared which was attached to Khalid.
"The universe is mine to command, to control!" Khalid laughed wickedly until he got shackles on his wrists. "What's going on?"
"You wanted to be a genie, you've got it!" Sonic smirked as he held the Khalid's lamp. "And everything that's yours with it!"
"NOOO!!!" screamed Khalid, when he realised that Sonic had tricked him into wishing to become a genie as he got trapped inside a lamp.
"Sonic, you did it!" smiled Tails as they gave each other a high five.
Everything was back to normal and the palace was reappeared in the city where it used to be. Sonic gave Tails the blue lamp so he used his magic to toss the lamp very far away from Rosagbah. And Chip and the carpet were back into their normal selves again.
After Khalid was gone. Amy walked next to Sonic.
"Amy, I'm sorry for lying about being a prince." Sonic said sadly.
"I know why you did." Amy said.
"Well, I guess this is goodbye?" Sonic said.
"That stupid law! This isn't fair! I love you, Sonic!" Amy said sadly.
"No problem, Sonic. You’ve still got one wish left. Just say the word and you’re a prince again." Tails smiled.
"But, Tails, what about your freedom?" Sonic asked.
"Well, it’s only an eternity of servitude." Tails shrugged. "This is love. Sonic, you’re not gonna find another girl like Amy in a million years. Believe me, I know. I’ve looked."
Sonic walked towards Amy and held her hands.
"Amy, I do love you! I’ve got to stop pretending to be something I’m not." Sonic said.
"I understand, Sonic." Amy said.
"Tails, I wish for your freedom!" said Sonic as he used his final wish to set Tails free which made his shackles disappear and his genie tail into legs with two fox tails.s
Tails was amazed and couldn't his eyes.
"I'm... I'm free... I'm free!" Tails smiled tearfully and hugged Sonic. "Thank you, Sonic! You're such a good friend! No matter what anybody says, you'll always be a prince to me!"
"You’ve certainly proven your worth as far as I’m concerned. It’s that law that’s the problem. Well, I'm the sultan and I can change that law. From this day forth, the princess shall marry whomever she deems worthy." said Robert.
When Amy heard her father's announcement about the new law. She smiled and hugged her father.
"Thank you, father!" smiled Amy and then she and Sonic embraced and kissed each other. Daisy stroked happily against Sonic and purred.
One beautiful starry and moonlit night with beautiful and colourful fireworks when Sonic and Amy got married, they kissed each other while they were on a carpet rigide in the beautiful moonlight.
And so they all lived happily ever after!