Duke Orsino of Illyria is in love with Olivia, but his advances are rejected. A shipwrecked Viola arrives on his shores, and with the help of a Captain disguises herself as a boy, calling herself Cesario, and enters Orsino's service. Orsino takes to Cesario, and sends him to woo Olivia for him. Viola, however, is already falling in love with Orsino.
Cesario arrives to woo Olivia, and Olivia falls in love with him. She rejects Orsino's approach, but asks Cesario to return. Orsino discusses the nature of love with Cesario, and sends him again to Olivia, who confesses her love for Cesario, much to his dismay.
Meanwhile, Viola's twin brother Sebastian, also a casualty of the shipwreck, arrives in Illyria with the help of Antonio, a sea-captain and former enemy of Orsino. Sebastian looks around the town, and Antonio gives him his purse to use, deciding to remain at the inn for safety. Staying with Olivia is her uncle Sir Toby, who is encouraging Sir Andrew, his drinking-companion and source of funds, to woo Olivia.
While carousing with Olivia's fool Feste late one night, they quarrel with Malvolio, and with the help of Olivia's maid Maria, they decide to trick him. Maria writes a letter to Malvolio, forging Olivias handwriting, to make Malvolio think Olivia loves him. The letter asks Malvolio to dress and behave in eccentric ways. Toby, Andrew, and Fabian observe Malvolio opening the letter and absorbing its contents. He approaches Olivia according to the letter's instructions, and she thinks him mad.
Toby arranges for him to be confined in a dark room. Later, he gets Feste to disguise himself as a priest, Sir Topas, to taunt Malvolio. Malvolio writes a letter of complaint to Olivia. Meanwhile, Andrew prepares to leave the house, having seen Cesario apparently being more successful with Olivia, but Toby persuades him to stay, and to challenge Cesario to a duel. Sir Toby separately informs Andrew and Cesario that the other is a ferocious fighter, and they approach each other with trepidation.
They are about to fight when Antonio arrives, intending to defend Cesario, whom he has mistaken for Sebastian. Antonio is arrested by officers who recognize him as Orsino's enemy. He asks for his purse from Cesario, who of course professes no knowledge of it. Feste is sent to bring Cesario to Olivia, but encounters Sebastian instead. They meet Andrew, who strikes Sebastian, thinking him to be Cesario, and Andrew is beaten for his pains. Olivia arrives to stop a fight between Sebastian and Toby. Sebastian is immediately taken with her. Thinking him to be Cesario, she is delighted that he has finally responded to her advances, and they go off to be married.
Orsino is told by Cesario of Antonio's arrival, but when Antonio is brought before him and asserts that he has been with Cesario for some time, Orsino thinks him mad. Olivia arrives, and again rejects Orsino's advances. As he and Cesario prepare to leave, Olivia insists on Cesario staying, and calls him her husband. When Cesario denies it, she presents the priest as confirmation. Orsino is enraged, thinking Cesario has betrayed him.
Toby and Andrew pass by, having just been severely beaten by Sebastian. Sebastian then arrives, and the twins delightedly recognize each other. Everyone is amazed, Viola's true identity is revealed, and she and Orsino decide to be married.
Feste delivers Malvolio's letter to Olivia, and he is brought from his cell. Fabian reveals the nature of the trick played upon him, and Malvolio leaves vowing revenge on them all. They all prepare for celebration, leaving Feste to bid the audience farewell.