In a deserted mountainous area, not far from the court of the Polish king, Rosaura, a noble lady dressed in a man’s dress and her servant, got lost. Night is approaching, and not a spark is around. Suddenly, the travelers distinguish in the twilight some tower, from behind the walls of which they hear complaints and moaning: this damns its fate chained in the chain of Sekhizmundo. He complains that he is deprived of freedom and the joys of life that are given to everyone born into the world. Finding the tower door unlocked, Rosaura and the servant enter the tower and enter into a conversation with Sehizmundo, who is astounded by their appearance: in his entire life the young man has seen only one person - his jailer Klotaldo. The sound of their voices rises asleep Klotaldo and calls the guards - they are all masked, which greatly affects travelers. He threatens death with uninvited guests, but Sehismundo decisively intervenes for them, threatening to put an end to his life if he touches them. The soldiers lead Sehizmundo, and Clotaldo decides, having taken the travelers' weapons and blindfolded them, to lead them away from this terrible place. But when the sword of Rosaura falls into his hands, something strikes the old man in it, Rosaura explains that the person who gave her this sword (she does not name him) ordered to go to Poland and show her to the most distinguished people of the kingdom, in whom she will find support - this is the reason for the appearance of Rosaura, which Klotaddo, like everyone else, takes for a man.
Left alone, Clotaldo recalls how he once gave this sword to Vyolante, saying that he will always help someone who brings it back. The old man suspects that the mysterious stranger is his son, and decides to seek the advice of the king in the hope of his righteous trial. For the same they turn to Basilio, king of Poland, infante Estrella and Muscovite prince Astolfo. Basilio is their uncle; he himself has no heirs, so after his death the throne of Poland should go to one of his nephews - Estrella, the daughter of his older sister Clorina, or Astolfo, the son of his younger sister Resismunda, who married in distant Muscovy. Both claim this crown: Estrella because her mother was Basilio's older sister, Astolfo because he is a man. In addition, Astolfo is in love with Estrella and invites her to get married and unite both empires. Estrella is not indifferent to the handsome prince, but she is embarrassed that on his chest he wears a portrait of some lady who does not show anyone. When they turn to Basilio to judge them, he reveals to them a carefully hidden secret: he has a son, the rightful heir to the throne. Basilio had been fond of astrology all his life and, before his wife had to be relieved of the burden, calculated from the stars that his son had a terrible fate; he will bring the death of his mother, and all his life he will sow death and discord around him, and even raise his hand against his father. One of the predictions came true right away: the appearance of the boy was worth his life Basilio's wife. Therefore, the Polish king decided not to jeopardize the throne, the fatherland and his life and deprived the heir of all rights, imprisoning him where he - Sechismundo - and grew up under the watchful guard and supervision of Clotaldo. But now Basilio wants to dramatically change the fate of the crown prince: he will be on the throne and will be able to rule. If he is led by good intentions and justice, he will remain on the throne, and Estrella, Astolfo and all the subjects of the kingdom will swear allegiance to him.
Meanwhile, Klotaldo leads to King Rosaur, who, touched by the monarch’s participation, tells her that she is a woman and ended up in Poland in search of Astolfo, connected with her by the bonds of love - it is her portrait that the prince of Muscovy carries on her chest. Clotaldo gives the young woman all kinds of support, and she remains at court, in the suite of the infantry of Estrella, under the name Astrea. Clotaldo, on the orders of Basilio, gives Sehismundo a soporific drink, and, sleepy, he is transported to the king’s palace. Here he wakes up and, realizing himself the sovereign, begins to commit atrocities, as if a beast has broken free, with everyone, including the king, is rude and harsh, throws from the balcony into the sea those who dared to contradict him, trying to kill Klotaldo. Basilio's patience comes to an end, and he decides to send Sehizmundo back to prison. “You wake up where you woke up before” - such is the will of the Polish king, which the servants immediately carry out, once again having drunk the crown prince with a sleepy drink.
Sehizmundo's dismay when he wakes up in shackles and animal skins is beyond description. Clotaldo explains to him that everything he saw was a dream, like his whole life, but, he says edifyingly, “in dreams / good remains good.” This explanation makes an indelible impression on Sehizmundo, who now looks at the world from this angle.
Basilio decides to hand over his crown to Astolfo, who leaves no claim on Estrella's hand. Infanta asks his new girlfriend Astrea to get a portrait for her, which the prince of Muscovy wears on her chest. Astolfo recognizes her, and an explanation occurs between them, during which Rosaura initially denies that she is she. Nevertheless, by hook or by crook, she manages to snatch her portrait from Astolfo - she does not want another woman to see him. Her resentment and pain knows no bounds, and she sharply reproaches Astolfo for treason.
Upon learning of Basilio’s decision to give the crown of Poland to the prince of Muscovy, the people revolt and liberate Sekhizmundo from prison. People do not want to see a stranger on the throne, and the rumor about where the crown prince is hidden has already spread across the borders of the kingdom; Sehismundo leads a popular rebellion. The troops under his leadership defeated the supporters of Basilio, and the king was already prepared for death, surrendering himself to the mercy of Sehismundo. But the prince changed: he changed his mind a lot, and the nobility of his nature prevailed over cruelty and rudeness. Sechismundo himself falls at the feet of Basilio as a loyal subject and obedient son. Sehizmundo makes another effort and steps over his love for Rosaur for the feeling that a woman has for Astolfo. The prince of Muscovy is trying to refer to the difference in their origin, but here the noble Clotaldo enters the conversation: he says that Rosaura is his daughter, he recognized her by the sword that was once given to her by her mother. Thus, Rosaur and Astolfo are equal in position and there are no more barriers between them, and justice triumphs - Astolfo calls Rosauru his wife. Estrella's hand goes to Sehismundo. With all Sekhizmundo is friendly and fair, explaining his transformation by the fact that he is afraid to wake up in prison again and wants to use happiness, like a dream.