This is one of the oldest stories/legends of St. Nicholas that happened while he was alive.
Having completed their mission, they had been sent to put down a revolt in Frigia, the three generals, Nepotianus, Ursos, and Eupoleonis, returned as conquering heroes to Constantinople. Emperor Constantine gave a great reception honoring the generals; this made the Master of the Forces green with envy.
The Master offered Prefect Ablabius a bribe of 1700 pounds of gold to betray the three generals. Agreeing, Ablabius went to Constantine, telling him, “My lord, the officers who were sent to serve you have instead committed treason. When I learned of this, I could not keep silent. Now, if it please my lord, act!” The furious emperor immediately ordered the three generals to prison without further inquiry.
The jealous officers, now afraid they would be found out, pressured Ablabius, saying, “Why do you keep the generals alive in prison? As long as they are there they can help their cause.” So Ablabius went again to Constantine, saying, “My lord, those generals that you ordered to prison, continue to plot against you.” The emperor ordered the men to be beheaded that very night.
The warden told the generals they were to be executed before sunrise. The three rent their garments, crying “What evil did we do, that we should perish so miserably?” For they had served the emperor loyally and well; now without trial, they were condemned by the same emperor. They knew not what to do.
Then Nepotianus remembered what they had witnessed in Myra, Bishop Nicholas saving three innocent men from unjust condemnation and death. He cried out, “Lord God of Saint Nicholas have mercy upon us. Save us now, as you saved the three men who were unjustly condemned to death in Lycia. Saint Nicholas, servant of Christ, though you are far from us, pray to your God that we may be saved.” They all prayed the same way.
Saint Nicholas himself came to Emperor Constantine in a dream, saying, “Rise and free the three generals you have put in prison, Nepotianus, Ursus, and Eupoleonis. They have been condemned on hearsay. If you do not obey, I will stir up such a revolt that your body will be given to wild animals.” Constantine asked, “Who are you, and how did you get into my palace?” The saint replied, “I am Bishop Nicholas, from Lycia.” And he vanished.
Nicholas then appeared to Ablabius the prefect, saying, “Rise and free the three innocent generals you have put in prison. If you do not listen to me, you and your whole family will die.” Ablabius asked, “Who are you and where do you come from, to speak to me like this?” Nicholas answered, “I am Nicholas, servant of God, the Metropolitan in Myra.” And again he disappeared.
Constantine awoke and sent a messenger for Ablabius. The prefect sent the messenger back with the same story. Constantine ordered the three generals, the prefect, and the public into his court. Constantine asked the generals, “What kind of magic do you do that you can affect us while we sleep?” The three stared at the ground, afraid of being accused of working spells on the emperor. The question was repeated. Nepotianus replied, “My lord, we know nothing of magic. If we have done anything against Your Excellency, punish us.” The emperor then asked, “Do you know anyone named Nicholas?” Inspired and emboldened, they answered, “Lord God of Saint Nicholas have mercy upon us. Save us now, as you saved the three men who were unjustly condemned to death in Lycia.” The emperor asked, “Who is this Nicholas?” Nepotianus told him what Nicholas had done, freeing the innocent men in Myra.
Emperor Constantine spared the generals, saying, “It is not I who frees you, but Nicholas to whom you called for help. Get dressed in your uniforms, and go to give him thanks.” Constantine sent them away with rich gifts of gold holy vessels, a Gospel of gold, and two golden candelabra. The generals journeyed to Myra to thank Bishop Nicholas for their amazing rescue. Nicholas brushed aside their thanks, urging them to praise God who had so miraculously saved them. They then gave of their wealth to the poor, continuing to do so for many years while giving thanks to God.