In the land of Agrabah, Rafi and his brother, Taj, watch their sibling, Cyrus, play a card game in which he bets using a golden compass. Cyrus wins the game with the help of the compass and prepares to collect the money pool when the other disgruntled players accuse him of cheating. As a fight nearly breaks out, the owner of the tavern barks at the instigators to leave, though the men threaten that Cyrus will pay for what he did. Afterwards, the brothers celebrate the victorious game with the remaining patrons. At night, the trio walk home to discover their house has been set aflame by the thugs from the tavern. Their mother, Amara, is grievously burned in the fire and may not survive. Rafi and Taj willingly go along with Cyrus' plan to travel to the Well of Wonders and collect magical water to heal her.
They arrive at a pavilion with a lakebed of water in the center. As they scoop up the water, the guardian of the well, Nyx, rises from beneath the surface. She states that the water can only heal those who are not yet destined to pass on, but knows Amara's fate is to die. Nyx warns them to return the water or pay the price. Cyrus chooses not to listen, deciding that he must set right the mistake he made in riling up the tavern men, and doesn't want their mother to pay the consequence for his own action. For their mother's sake, Rafi and Taj decide to follow through, and Amara is healed using all three canteens of water that they procured from the well. Rafi accidentally lets it slip that they revived her using water from the Well of Wonders. In a panic, she urges them to leave Agrabah before Nyx comes, but her warning comes too late. Nyx curses the three brothers, entrapping them in different bottles as genies, to serve the desires of other people. ("Dirty Little Secrets")
As a genie, Rafi presumably carries out his duty of granting three wishes to whomever summons him out of the bottle. The sorcerer Jafar gains Rafi's bottle as well as Taj's in his quest to change the laws of magic. ("The Serpent")