Two men steal a box and they soon find themselves in the scorching desert, until they kill one another. A third man wakes up riding an animal in the middle of the vast desert. Believing he must be on a film set, he searches for the director and the cast to leave the place.
The man puts on the clothes he found and disguises himself before he ventures into the city. Meanwhile, the ruler's men search for the dagger that was stolen from the box. They fetch the culprit to the ruler. Tawfik goes to the Jewish man to find the treasure.
The accused man tells the ruler that two criminals beat him up and took the box away from him. In Al-Madinah Al-Hamraa, Tawfik watches Ja'far. Tawfik enters the ruler's chamber saying he is a private detective, and he wants to ask Hadidan a couple of questions.
Hadidan earns the ruler's favor, and Tawfik tells the public that Hadidan is known for his honesty and integrity. Tawfik and Hadidan soon become friends, which infuriates Ja'far, who knows at heart that Hadidan is a deceitful liar.
Ja'far searches Hadidan's house and finds some gold as well as the ruler's dagger. Ja'far arrests Hadidan and takes him to the ruler, as Ja'far inquires about who murdered the guards of the treasury. Tawfik tries to free Hadidan.
Hadidan tells Ja'far he saw him with the gang and will report it to the ruler. In retaliation, Ja'far starts a rumour that Hadidan ran away from prison. A commoner tells the ruler that Ja'far is keeping a secret, and that his guards are not trustworthy.
The ruler confronts Ja'far with what the daughter of a commoner told him; Ja'far threatens the girl and has Hadidan locked up at his house. Ishak's fortune is stolen. The commoner visits the ruler to alter his daughter's statement. Tawfik smuggles Hadidan out.
Hadidan dons a woman's disguise and runs away. Ja'far gives orders to find Hadidan. Hadidan and Tawfik hide inside a box, but they travel in time and find themselves in Ancient Egypt.
In Egypt, Hadidan finds his son and wife in the King's palace. The King has Hadidan and Bu Sh'ieb locked up until he figures whether they are people or Jinn. The King looks for the book that protects Egyptians against their enemies, but only his ruling partner has a copy of it.
Hadidan captures photos of the prison walls with his phone. Hadidan and Bu Sh'ieb futilely try to run away. The Princess wants her guards to stand by her against her ruling partner. Hadidan and Bu Sh'ieb try to earn the King's favor.
The Head Shaman asks Hadidan how they got into the box. The Princess tells her attendant that she has the book her partner in power is looking for. The King forgives the two men, and the King's mother offers them food.
The Princess refuses to give the book away, but she states that the two time-traveling men are mentioned in it. Hadidan starts to train men and has some authority over the servants.
The Prince tells The People's Master that the Princess accepted their reconciliation. At the Palace, the Princess likes Bu Sh'ieb and decides to wed him and announce him Emperor. The guards look for the box that has all the keys of the palace.
When Bu Sh'ieb pulls out his phone, everyone grows frightened, and the Princess tells them Hadidan and Bu Sh'ieb will get them killed. When the People's Master considers killing and mummifying them, his mother tells him they're not worthy of it.
Hadidan and Bu Sh'ieb run away. Hadidan's son, Khamis, becomes King, and his grandmother offers advice and consultation.
While Hadidan and his friend are still looking for an exit, the Prince looks for them. When a gang catches them, Hadidan recounts their story to the gang members, only for the leader to decide to send them to Caesar.
Hadidan tells the leader that he knows where the treasure is. The Pharaohs are still looking for the duo. The Princess tells her servant that she thinks the box has a curse.
The Prince notices Hadidan's footsteps. The pirate tries to convince Hadidan and Bu Sh'ieb to embark with them on a treasure hunt across the sea. The gang arrests one of the Pharaohs. The pirate tells Hadidan he wants to exact revenge on the Prince because he gouged out his eye.
Hadidan and Bu Sh'ieb part ways. In the endless desert, Hadidan grows weary and thirsty, but he rejoices when he meets Bu Sh'ieb. The Young Prince is still looking for the duo, while Hadidan faints.
As both men pass out in the desert, some Bedouin men find them and save them. The girls of the tribe try to figure out who the men are. After some trouble with the tribe, Hadidan and Bu Sh'ieb plot their escape.
Bu Sh'ieb accepts the offer of the daughter of the tribe leader to work with them in trade. The females of the tribe try to approach Hadidan and Bu Sh'ieb. As Bu Sh'ieb gets engaged to the leader's daughter, Hadidan reminds him they're in the wrong place and time.
The Queen forgives Hadidan and Bu Sh'ieb and sends them into the box so they can return back to where they came from. The box takes the duo back to their previous prison. The ruler is ill and his daughter believes Ja'far is behind it.
Hadidan offers J'afar all the gold and jewelry they have to free them. The ruler tells his doctor he feels that his end is near. With the Princess out in the city, Ja'far imprisons the leader and declares himself the new ruler.
Hadidan's mother-in-law meets Ishak. The sage looks for Hadidan. The previous Sheikh is dismissed and Hadidan assumes his position.
The Ruler, Hadidan, and Bu Sh'ieb are freed, and Ja'far is sent to prison. Hadidan urges Bu Sh'ieb to keep their time-traveling journeys a secret. The Ruler returns to the palace, while Hadidan returns to his family.
The people rejoice when Hadidan and Bu Sh'ieb return, but they want to learn who stole the treasure. Hadidan's son finds the box and gets into it.
Hadidan's boy gets out of the box. Hadidan and Bu Sh'ieb try to persuade Qassem to work with them in trade.
Hadidan and Bu Sh'ieb get into Qassem's house to get his bag. While waiting for the burial to take place, Qassem is resurrected from death and his family rejoices. Qassem begs for forgiveness. The Ruler honors Hadidan for his honesty and his loyalty to the country.
The Ruler decides to burn the box, but Hadidan tries to extinguish the fire. Bu Sh'ieb enters the box and bids Hadidan farewell. Hadidan and Qassem reconcile.
A young man with countless stories enters the markets, and the people are hyped to hear what he has to say. When Ja'far re-emerges and decides to arrest Hadidan, Hadidan and the storyteller disappear into the sky.