The eccentric, unsuccessful architect Harold Ventimore, Tony Randall is taking the next big step in his life: he has become engaged to his girlfriend Sylvia Kenton, Barbara Eden. Her father Anthony Kenton, Edward Andrews, an Egyptology professor, immediately interrupts a trip to Europe and returns to the United States to prevent Harold from marrying Sylvia. To make his future in-laws happy, Harold buys a large, sealable oriental brass bottle at an auction, only to discover that they had bought the same one the day before, so he takes the vase back with him.
When Harold opens the lid of the bottle, he unwittingly releases the djinn Fakrash Al-Amash, Burl Ives who was once imprisoned in the container by King Solomon 3,000 years ago. Harold, suspecting Fakrash is pulling a joke, calls the police, but when they arrive, the djinn has disappeared. The next day, he is visited by Samuel Wackerbath, Parley Baer, who wants to build a new settlement and chooses Harold, granting him a generous advance. The djinn reappears, admitting that he put the idea in Wackerbath's ear. Harold's boss William Beevor, Philip Ober, suspects he is doing business behind his back and throws him out of the company. Harold uses the advance to open his own architect's office.
One evening, Harold invites Sylvia and her parents to dinner. He is horrified to discover that his living room has been transformed into an oriental dining room complete with slaves, harem girls, and even a belly dancer. The shocked Kentons start to leave, while Harold tells Anthony about the djinn and the bottle, but Anthony, Edward Andrews, the chagrined father, rudely rejects him. Fakrash tries to instigate Harold to end his relationship with Sylvia, offering him many women. When Harold replies that polygamy is forbidden in the US, Fakrash conjures Tezra, a princess of the blue djinn, Kamala Devi, but Harold insists on remaining faithful to Sylvia.
Fakrash, Burl Ives, unsuccessfully tries to conjure away Tezra, as blue djinns have their own magic powers and she doesn't want to leave Harold. The next day, Sylvia, Barbara Eden, visits Harold with a psychoanalyst but assumes he is cheating on her with Tezra and leaves.
Harold asks Fakrash to reveal himself to Anthony, Edward Andrews who rudely rejects him; Fakrash turns Anthony into a mule. Six months later, Fakrash and Harold have ‘built’ over a thousand houses. The state authorities, realizing that such mass construction could not have been done in a short amount of time, open a commission of inquiry. When Harold testifies that Fakrash is a djinn, he is committed to a locked psychiatric ward. Fakrash seeks him out and defends him in court by displaying his powers, but this causes new problems. Fakrash explains that he can reset everything to the way it was before Harold met him, and he grants Harold's wish to do so. Harold returns with no memory of Fakrash to when Mr. Wackerbath visits him to offer him the settlement project. He also introduces him to his partner and his wife, though Harold does not recognize them as Fakrash and Tezra.