Act I – The Outlaw
Ernani, the leader of a band of outlaws, reveals his love for Elvira, lamenting that he will lose her forever to the aged grandee Don Ruy Gomez de Silva, who plans to marry her the next day. Ernani asks his men to help him abduct Elvira, who sworn to follow him. Elvira's coming marriage to Silva horrifies her, and she longs for Ernani to carry her away. Don Carlo, King of Spain, who also loves Elvira but knows she prefers Ernani, arrives, eager to persuade her to forsake both the outlaw who is his fierce enemy and the grandee. The King ignores Elvira's icy reception, provoking her into threatening both their lives with a dagger. When Ernani appears, ready to abduct Elvira, she attempts to end the hostility between him and the King. Ernani will have vengeance as the King's father deprived his own father from his honor and his life and now the King wants to take away his beloved. Unexpectedly, Silva appears and is outraged to find the men with his betrothed and without recognizing the intruders, he challenges them to a duel. When the King's identity is revealed Silva is deeply embarrassed. Forgiving him, Carlo announces he will stay the night in Silva's castle, thereby entitling him to the old man's protection due to the laws of hospitality. Carlo reveals to Silva that he hopes to be elected the new Emperor and lets Ernani leave in peace, proclaiming him to be his loyal subject.
ACT TWO – The Guest
Guests are gathered in the hall of Silva's castle to celebrate his marriage to Elvira. Silva offers hospitality to a pilgrim, who is actually the disguised Ernani. When Ernani learns that Elvira is to marry Silva, he throws off his disguise, offering as a wedding present his life and the reward the King has offered for it. Silva replies that his hospitality is sacred and protects all his guests, even form the King's anger. He orders his men to guard the castle's towers. Returning alone, Elvira explains to Ernani that hearing the report of his death, she consented to marry Silva, but planned to take her own life at the altar. As the reunited lovers embrace, Silva surprises them. Before the old man can vent his rage, Jago enters to announce that the King has arrived to the gates. Silva gives orders for his welcome. The laws of honor and hospitality require him to protect Ernani as long as the bandit is under is roof. He orders his guest into hiding and then sends Elvira back to her apartment.
Don Carlo now enters and accuses Silva of rebellion, having noticed the armed men at the castle's towers. When Silva replies that he is a loyal subject, Carlo commands him to prove this by surrendering Ernani, who has been traced to the castle. Silva's sense of honor prevents him from complying and the King issues an ultimatum: Ernani's head or Silva's. Silva offers hiss own head and surrenders his sword to the King, who orders his men to search the castle for Ernani. The King's men report that their search has failed. As the king is about to leave ordering torture to force the secret from the castle defenders, Elvira rushes in to beg the King for clemency. Carlo realizes he now has a new advantage: he demands Elvira – Silva's betrothed – as a hostage for the outlaw, and leads the unwilling lady away.
Ernani comes out of hiding and Silva challenges him to a duel, but the bandit refuses the uneven contest with an elderly opponent. He declares that he owes his life to Silva and asks to see Elvira once more before he dies. Upon learning that Elvira has been taken hostage, he persuades Silva to let him join the effort to rescue her. He makes a solemn vow to take his own life whenever Silva wishes, and gives the old man his hunting horn to sound at the moment he wishes to claim the forfeited life.
ACT THREE - Clemency
Knowing that his life is in danger and that his enemies are to gather at Charlemagne’s tomb in Aix-la-Chapelle, Don Carlo arrives with Riccardo to spy on the conspirators who plan to assassinate him. As the electors of the Holy Roman Empire are about to choose a new emperor, the King tells Riccardo to fire the tower's cannon three times if he has been selected. In that event, Riccardo is to bring Elvira to him. Alone, the King vows to emulate Charlemagne's virtues and prove himself worthy if he is elected emperor. The conspirators gather and then draw lots to determine who will strike down the King. Ernani is elated when he is chosen yet Silva asks Ernani to yield the task to him. Despite offers to release the hold Silva has on his life, Ernani refuses and Silva renews his threat of vengeance. Three cannon shots proclaim Carlo's election as Emperor. He emerges from the chapel to defy the conspirators as a procession of electors arrives for his investiture. He decrees prison for the commoners among the conspirators and death for the noblemen. Ernani, whom the guards have placed among the nobles, reveals his true identity as Don Juan of Aragon. Elvira, who had arrived in the procession of electors, pleads for his clemency. Contemplating the tomb of Charlemagne, Carlo declares he will imitate the acts of his great predecessor. He pardons all the conspirators, and then orders the marriage of Ernani and Elvira.
ACT FOUR – The Masker
Ernani's title has been restored to him, and guests are now enjoying the festivities following his wedding to Elvira. A masked stranger whose attire and attitude contrast sharply with the joyful wedding guests, now appears. Ernani, who has been rejoicing in his happiness with Elvira, is startled by the sound of a hunting horn. Increasingly unnerved, he sends the mystified Elvira to the bridal chamber to fetch some medicine. Alone, Ernani wonders if he just imagined the horn. Suddenly the masked guest reveals his identity: it is none other than Silva, who has come to force Ernani to keep his word. He offers Ernani the choice of poison or a dagger. Elvira returns and is horrified yet the lovers' pleading is useless – Silva insists on the vengeance due him. Unable to break his vow, Ernani stabs himself.