Set in the days of 12th century, Abu Hassan, a notorious bandit, is having a reign of terror on the people of Gulabad (city of flowers). No caravan is able to trade safely as all the money is looted and people killed by 40 cronies of Abu Hassan. In one such caravan, are traveling Fatima and her father; a person who knows how to make gun powder. When Abu Hassan along with his thieves attack the caravan, he throws bags filled with gun powder on them but unluckily, Abu Hassan manages to loot them and hostage him and Fatima to his cave. Fatima is then used as a spy to get the knowledge of caravans arriving in the city in return for life of her father. But her father knowing that Fatima has been trapped in their net due to him, gives her a letter and tells her not to open it unless she is out of the cave. When Abu Hassan lets Fatima go out of the cave for spying, she reads the letter which is in fact a suicide note informing her that she is now free and need not to come back as her father will be dead by the time she would be reading that note. Meanwhile, Alibaba, a young man finds a letter from the king that his father has been found by the king and is living there as he is too weak to return home. Alibaba goes to the palace to bring his father who had gone for trading years ago and could not manage to return home so long that Alibaba could not identify him. On the same day when Alibaba reaches the palace, the General has taken command from the king and killed him while the king's daughter, Princess Marjina, is running for her life. Check out how fate united Alibaba, Marjina and Fatima to free the people of Gulabad out of the reign of terror of Abu Hassan.—Mohsin Ali Khan
Alibaba, (Dharmendra) a native of Guleba is in love with Marjina (Hema Malini). The town has a ruler, Abu Hasan. Guleban is terrorized by dacoits. Ali Baba hears the password to the door of the cave of the dacoits and takes a lot of jewels from the cave. His brother is killed by the dacoits as he forgets the password and is trapped inside. A young girl whose father has been murdered by the dacoits (Zeenat Aman) has a score to settle with Abu Hasan. Abu Hasan turns out to be the head of the dacoits and he comes to know that Ali Baba visits the cave. He hides the 40 thieves in large urns to kill Ali Baba. Ali Baba comes to know of this and kills them all. He brings to light the startling truth that their own ruler heads the dacoits!