Like many folk tales, "Ali Baba and the Forty Thieves" has no known author. It was first added to an edition of "One Thousand and One Nights" by French translator Antoine Galland.

Galland claimed that he heard the folk tale in Aleppo, Syria. However, some scholars argue that Galland made up the story himself, since no documentation of the story in old Arabic records has ever been found. It does not appear in the oldest copy of "The Thousand and One Nights," which is an Arabic manuscript from the 14th century. In "One Thousand and One Nights," the storyteller Scheherazade tells "Ali Baba and the Forty Thieves" to her husband, the Persian king Shahryar.