A swampy riverside region near the Hungarian village of Banat in the Temesvar Province. The distant scene is dominated by a derelict castle. In the foreground is a partly deserted village with only one reasonably prosperous-looking house. In a particularly disreputable hut there lives an old gypsy woman named Czipra. The boatmen can be heard singing at their work. Ottokar, son of Mirabella who is governess to Arsena (daughter of a miserly old farmer Zsupán) is digging for treasure which he fondly believes to be buried somewhere around. This is his daily routine which, the more he looks without success, the worse becomes his temper. Czipra looks out of her window and makes fun of his efforts. She has been watching him for weeks and has a low opinion of his time-wasting while the other gypsies are out doing an "honest" day's work. She tells him that if he continues with this fruitless quest, he will end up penniless and never marry, as he hopes, the fair Arsena.
Sándor Barinkay, son of the late owner of the castle, arrives accompanied by Conte Carnero, Commissioner for Oaths, who is here to sort things out for him. The Commissioner suggests they get on with the job and call on Czipra as a witness. They send for Zsupán. In the meantime he tells Barinkay of the beautiful Arsena. To pas time Czipra tells their fortunes and reveals to Sándor Barinkay that there is happiness and fortune in store for him. He will marry a faithful wife who will, in a dream, discover where the treasure is hidden. Carnero is also told that he will recover a treasure that he has lost, which leaves him slightly puzzled as he cannot remember having had one.
Zsupán arrives and tells everyone that he is a highly successful pig-breeder adding that he lives for sausages and wine and has little time for art. He agrees to witness Barinkay's claims but warns him that he can be a contentious neighbour. Barinkay suggests that he might marry Zsupán's daughter and Arsena is sent for. But it is Mirabella, the governess, who first appears. It seems that she is Carnero's long-lost wife, so part of Czipra's prediction is immediately realised. Carnero shows little sign of delight and a rather joyless reunion takes place. Mirabella says that she had believed her husband to have been killed at the Battle of Belgrade.
Arsena arrives, heavily veiled, but though the chorus hail the bride-elect she is not so co-operative. She is in love with Ottakar. Barinkay makes a formal proposal but Arsena tells him that she is descended from the aristocracy and can only marry someone of noble birth. Zsupán and the others tell Barinkay that he must do something about this. He is left brooding but hears a gypsy girl singing a song which praises the loyalty of the gypsies to their friends. It is Saffi, daughter of Czipra, and Barinkay is immediately attracted by her dark beauty and accepts an invitation to dine with her and Czipra. Unaware of the others watching, Ottakar meets Arsena and they vow their eternal love for each other. He gives her a locket at which point Barinkay pretends to be most indignant. The gypsies return form their work and Czipra introduces Barinkay as their new local squire. They elect him chief of the gypsies. Now affirmed as a gypsy baron he calls on Zsupán and asserts his noble right of the hand of Arsena. Zsupán is not all that impressed. Saffi welcomes Barinkay back to his inheritance. Ever the opportunist, Barinkay now says that he would like to marry Saffi who is as delighted as her gypsy friends. Zsupán and Arsena are now rather indignant at this turn of events and threaten reprisals.
The castle at dawn on the following day. Czipra reveals to Barinkay that Saffi has dreamed of the location of the treasure. They start to search and find it hidden, as she has dreamed, under a nearby rock. As they depart the gypsies arise to start their day's work. Zsupán appears and tells them that his cart has stuck in the mud. He orders the gypsies to come and help him. They resent his order and steal his watch and money. His cries for help bring Carnero, Mirabella, Ottakar and Arsena on the scene, followed by Barinkay, now dressed as a gypsy baron, and Saffi. Barinkay introduces Saffi as his wife but Carnero is not satisfied that all the legal requirements have been met. They tell him the stars have guided them and the birds have witness their vows. This is not quite what the law demands and Mirabella and Zsupán adopt a highly moral tone about the whole affair. At this point Or=Ottakar discovers a few of the gold coins that Barinkay has left behind and is highly excited. Barinkay soon disillusions him by telling him that the treasure has already been found. At this moment, a recruiting party arrives under the command of one of Barinkay's old friend, Count Peter Homonay. He is looking for recruits to fight in the war against Spain. Zsupán and Ottakar are press-ganged into the army. Carnero calls on Homonay to give his official support to the view that Barinkay and Saffi's marriage is illegal but Homonay supports Barinkay. Further complications, however, are revealed. Czipra tells them that Saffi is not really her daughter but the child of the last Pasha of Hungary, a real Princess. Barinkay is once more deflated realising that he cannot marry anyone of such exalted rank, though Saffi says that she will always love him. Barinkay decides that he too will join the Hussars and the men march away leaving behind three broken-hearted ladies.
After a victorious battle all are celebratin in Vienna. Zsupán appears and tells of his own, somewhat inglorious, exploits in Spain. Homonay, Barinkay and Ottakar reveal that they are heroes of battle and have been made into genuine noblemen. There is now no objection to the marriage of Saffi and Barinkay or Ottakar and Arsena. A truly happy ending has arrived.