1. In the kingdom of Illyria, the Duke Orsino laments over his unrequited love for the Lady Olivia, who is in mourning for her brother and has refused to see anyone for seven years.
2. Meanwhile, a ship has been wrecked by a storm off the coast, casting the young noblewoman Viola onto shore. Finding herself alone with the Captain, Viola assumes that her twin brother, Sebastian, with whom she was traveling, is dead. Grieving, she learns from the Captain—who, by chance, was born in Illyria—about the region, and decides that she would like to conceal her identity and offer her services to this Lady. However, after the Captain informs Viola that Olivia refuses to see anyone. Viola resolves to conceal her identity—she dresses up as a pageboy, Cesario, and go work for Orsino. The Captain agrees to help.
3. Viola advances quickly in Orsino's household. However, she soon finds herself falling in love with Orsino—a love which she cannot pursue, since Orsino believes her to be (the male) Cesario. At the same time, when Orsino sends Cesario to Olivia's house to woo her in his stead, Olivia becomes passionately attracted to "Cesario." Only Viola understands the love-triangle that her disguise has brought about: she loves Orsino, Orsino loves Olivia, and Olivia loves her. None of these loves can be fulfilled.
4. While the plot between Orsino, Viola, and Olivia unfolds, scenes at Olivia's house introduce a second group of characters: Olivia's uncle, the drunkard Sir Toby; his equally vulgar friend and suitor of Olivia, Sir Andrew Aguecheek; Olivia's charming lady-in-waiting, Maria; the clown, Feste; and Malvolio, Olivia's self-important steward, who constantly scolds and irritates the rest of them. Maria devises a prank to get even with Malvolio. She forges a letter, supposedly from Olivia, addressed to a secret beloved "M. O. A. I."; the letter instructs its anonymous addressee to wear yellow stockings and crossed garters, to act haughty, smile constantly, and refuse to explain himself in order to show that he returns Olivia's affections. Malvolio finds the letter and assumes that he himself must be "M. A. O. I." Following "Olivia's" instructions, he behaves so oddly that she worries that he has gone mad.
5. Viola's twin brother Sebastian soon arrives up in Illyria: he was saved from the shipwreck by a local, Antonio, but thinks his sister is dead. Antonio has grown so attached to Sebastian that he follows him into Orsino's territories despite the fact that Orsino is an old enemy.
6. When Sir Andrew starts to notice that Olivia is in love with Cesario, Sir Toby encourages him to challenge Cesario to a duel. They are just about to fight when Antonio shows up and asks to defend Cesario, whom he mistakes for Sebastian. (Viola, in her disguise, looks exactly like her twin brother.) When Orsino's police show up and haul Antonio off, Cesario slips away. But then Sebastian happens to arrive on the scene. Sir Andrew and Sir Toby resume fighting—mistaking him for Cesario. Sebastian is baffled, but defends himself. Olivia shows up during the scuffle and, mistaking Sebastian for Cesario, calls Toby and Andrew off at once. She immediately asks Sebastian to marry her. Sebastian is mystified. But, seeing that Olivia is beautiful and wealthy, he accepts her offer.
7. Meanwhile, Olivia's belief that Malvolio is mad, has allowed Maria, Toby, and the others to lock him up in a dark cell for "treatment." They enjoy tormenting and mocking him. However, Sir Toby starts to get worried, since he knows how angry Olivia already is with him for attacking Sebastian (or, as she thinks, Cesario). Therefore, they let Malvolio send a letter to Olivia, arguing his case and demanding to be released.
8. Cesario and Orsino visit Olivia's house. Olivia welcomes Cesario as her husband, thinking that he is Sebastian. Orsino is shocked and enraged, but when Sebastian himself arrives on the scene, everything falls into place. Viola and Sebastian are reunited. Now aware that Cesario is in fact the woman, Viola, Orsino declares that he is in love with her and asks her to marry him. It is reported that Sir Toby and Maria have also married privately. Finally, Olivia remembers Malvolio and summons him out of the dark room. Furious, he accosts her. When she tells him he should not take things so seriously, he threatens that he will have revenge against them all and storms off. The happy couples await their marriage ceremony.