From the Super Mario Wiki
In The Super Mario Bros. Super Show! episode "Mario's Magic Carpet", Mario, Luigi, Toad and Princess Toadstool go out to search for Aladdin's Lamp, believing they could use its power to defeat King Koopa.
It was eventually revealed that Aladdin's Lamp was among the collection of treasure of a gluttonous sultan named Sultan Pasbah. Mario, Luigi and Toad, after escaping imprisonment by Sultan Pasbah, managed to steal Aladdin's Lamp, planning on using its power to escape from Sultan Pasbah's clutches, along with saving Princess Toadstool.
Eventually, Mario manages to release the genie of Aladdin's Lamp, who turned out to be extremely obnoxious and a crank. After the genie was released, Aladdin's Lamp remained stuck on her foot for a large portion of the episode.
The genie later re-entered her lamp rather than spend anymore time with Mario, Luigi, Toad and Princess Toadstool. The lamp proceeded to throw itself off the magic carpet it was on, only to land on King Koopa's magic carpet; the genie then exited Aladdin's Lamp and begin to furiously annoy King Koopa.