At the beginning of the frame story, Vikramaditya king of Ujjain receives, among other visitors, a mendicant who presents the king a fruit on every visit. In the fruits are later discovered orbs of ruby. Upon this discovery, the king resolves to visit the mendicant, who arranges a meeting under a banyan tree in a cremation ground beyond the city, at night, on the 14th day of the dark half of the month. At the meeting, the mendicant requests that Vikramaditya bring him a corpse suspended from another tree, with which the mendicant might achieve occult power.
Upon Vikramaditya's doing so, the corpse is identified as Betaal, the ghost, who narrates a story to the king, concluding that Vikramaditya must answer a moral question pertaining to the story's characters, on pain of his own death; and upon his answering the question, Betaal returns to his tree. This sequence repeats 25 times until Betaal reveals the mendicant's plan was to kill the king after obtaining power from Betaal himself. Thus forewarned, Vikramaditya kills the mendicant after their meeting.