Where the story of Aladdin comes from is not known with any great certainty. One of the most popular tales from what are known variously as the One Thousand and One Nights, 1001 Arabian Nights, The Arabian Nights, or The Arabian Nights’ Entertainments, it wasn’t included in the collection until a French edition translated by Antoine Galland in 1710. In fact, a number of the most popular and famous stories from One Thousand and One Nights, including Ali Baba and Sindbad, were not part of the original collection.
In its original shape, One Thousand and One Nights is a flexible anthology of Middle Eastern folk tales collected during the Islamic Golden Age. Between the 8th and 13th centuries CE, the Islamic world went through a period of tremendous cultural, scientific, and artistic advancement. This period was fluid, acting, reacting, and interacting with a variety of cultures. The preservation of Greek writings by Eastern Christianity and Christianity’s invention of concepts like the hospital and university helped develop the framework of the Islamic Golden Age, and extensive trade brought knowledge and ideas from the corners of Africa, India, and Asia. Knowledge also worked its way through the Middle East to these regions and to Europe, reintroducing Western Christianity to Greek philosophy. The story of Aladdin reflects this by making Aladdin himself a Chinese man (despite his distinctly Arabian name meaning "nobility of faith" or "faithful" and being specifically identified as a "Mussulman," which is an archaic term for Muslim) and the evil magician from North Africa. In the world of the original teller of the story, whoever that may be, those would have been farthest Western and Eastern reaches of the Earth.
Among the things imported from India and Persia were a group of stories collected and translated into Arabic as The Thousand Nights. This formed the nucleus around which The One Thousand and One Nights accumulated. The oldest known fragment of the text dates to the 9th century, and the earliest reference to it in another text dates to the 12th. The variable number of stories included in The One Thousand and One Nights were all linked by the framing story of a jilted Sultan who executed his wife for her infidelity. Each evening he would take a new wife, and each morning thereafter have her executed before she could betray him. The last was Scheherazade, who preserved her life by telling the Sultan a fragment of a story each night, leaving him too curious about what happens next to have her executed. After her last story ended on the 1001st night, the Sultan had a change of heart and they both lived on in marital bliss.
The first European translation of The One Thousand and One Nights began in 1704 from the pen of Antoine Galland, a French archaeologist and scholar on the Middle East. Besides translating extant copies of the original story, he took it upon himself to add other folktales he had come across in his journeys. He did not have to travel very far to find the story of Aladdin: according to his own account, he heard it in Paris from a Christian monk visiting from Aleppo, Syria. No known Arabic original of Aladdin's story exists, and scholars are divided over whether it is an authentic Middle Eastern tale or whether Galland made it up. It is known that he adapted his translation to the tastes of the time and the vogue for fairy tales that were increasing in popularity. Later translations by the likes of Sir Richard Burton reintegrated the more questionable and erotic passages excised by Galland. Left in Galland's version were the attitudes towards race prevalent at his time.
The following translation and abbreviation of Galland was by Kate Douglas Wiggin and Nora Smith for a 1909 edition of The Arabian Nights: Their Best-Known Tales. Acknowledging that "It would be a delightful task to any boy or girl to begin at the beginning and read the first English version of these famous stories, made from the collection of M. Galland, Professor of Arabic in the Royal College of Paris" they are still forced to admit that "We, like many other editors, have shortened the stories here and there, omitting some of the tedious repetitions that crept in from time to time when Arabian story-tellers were adding to the text to suit their purposes."
Even with these edits, the story of Aladdin is still a brisk 31,400 words. I've posted it here in its entirety, so buckle in and keep your hands, arms, feet, and legs inside the carpet at all times...