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!