Alithea Binnie, a British scholar with a specialization in narratology, often experiences hallucinations involving demonic entities. While visiting Istanbul, she stumbles upon an antique bottle, inadvertently releasing a trapped Djinn, played by Idris Elba. This Djinn offers her a chance to fulfill three wishes, but with strict conditions: no wishing for more wishes, no immortality, and no wishing for an end to sin or suffering. Alithea is skeptical and challenges the Djinn's intentions, asserting that making wishes ultimately leads to regret. She reminisces about her childhood where she conjured an imaginary friend who she created a whole life story for in her diary, only to abandon him out of fear of being overwhelmed by her imagination.
In response to her hesitations, the Djinn recounts three captivating tales from his past that explain how he became imprisoned in the bottle.
The first tale narrates the story of the Queen of Sheba, who is both the Djinn's kin and beloved. In a tale of jealousy, King Solomon imprisons the Djinn in a brass bottle, which is subsequently cast into the Red Sea by a bird. After twenty-five centuries, the bottle is retrieved by fishermen, only to be repurposed as a stone in a wall.
The second story revolves around Gülten, a concubine in the court of Suleiman the Magnificent. After discovering the bottle, Gülten wishes for the affection of Suleiman's son, Mustafa, a desire that leads to tragic consequences. Influenced by the cunning Hürrem Sultan, Gülten's desires culminate in betrayal and death, leaving her unfulfilled even before she could make her final wish.
Having failed to fulfill her final wish, the Djinn endures over a century of invisibility in the palace, where he closely observes the rise and fall of rulers like Murad IV and Ibrahim. During this time, his bottle is rediscovered by a favored concubine named Sugar Lump, who despite her initial skepticism, ultimately entraps him once again, believing him to be a deceitful being.
The last of the Djinn's stories shares the plight of Zefir, a young wife of a Turkish merchant, who comes into possession of the bottle in the mid-19th century. Yearning for wisdom and understanding, Zefir makes wishes that deepen the bond between her and the Djinn. However, her desire for independence leads her to wish for oblivion, sealing the Djinn's fate once more.
Moved by these poignant narratives, Alithea recognizes her growing affection for the Djinn. For her first wish, she desires him to love her as he once loved Zefir. Their connection blossoms, and they explore the world together once she returns to London. However, Alithea soon discovers that the modern environment is debilitating the Djinn; the constant interference from city technology threatens his very existence. Desperate to save him, she uses her second wish to uncover his voice, expressing her regret for their stolen time. Finally, with deep sorrow, she makes her third wish: to release the Djinn, allowing him to return to "The Realm of Djinn," realizing that he cannot thrive amongst humans.
In the years to come, Alithea pens down a book detailing the Djinn's enthralling stories, reminiscent of the fantasies of her youth. One day, as she strolls through the park, she spots the now-healthy Djinn approaching her. Joined in a tender embrace, they walk hand in hand, with Alithea's narration promising that he will always return throughout her lifetime.