Algernon Moncrieff prepares for the arrival of his aunt, Lady Bracknell, and her daughter, Gwendolen, in his stylish London flat in 1895. His butler, Lane, brings in "Ernest Worthing" (who is listed as "John Worthing" in the cast list and "Jack" in the body of the play, although both Lane and Algernon believe his name is Ernest), who has just returned from the country. Jack reveals he has come to London to propose to Gwendolen. Algernon ridicules the notion of marriage, and says that before Jack can marry Gwendolen, he has to clear up the issue of Cecily. Algernon orders Lane to bring in Jack's cigarette case and shows the inscription: "'From little Cecily, with her fondest love to her dear Uncle Jack.'" Jack says his name is Ernest in town and Jack in the country. Algernon says he has always suspected Jack was a "Bunburyist," and now he has proof.
Jack explains that Thomas Cardew, who adopted him, willed Jack to be guardian to his granddaughter, Cecily. Cecily now lives at Jack's place in the country under the guidance of her governess, Miss Prism. Since Jack must maintain a high level of morality to set an example, he needs an excuse to get into town. He has invented a ne'er-do-well younger brother named Ernest who lives in Albany, and whose problems frequently require Jack's attendance. Algernon confesses that he has invented an invalid in the country, Bunbury, for when he needs to get out of town. Jack insists that he is through with "Ernest," but Algernon maintains that he will need him more than ever if he marries.
Lady Bracknell and Gwendolen arrive. Algernon tells Lady Bracknell that he will be unable to attend her dinner tonight, as Bunbury is ill. They go into the music room. Jack confesses his feelings to Gwendolen, and she admits that she likes him, too, especially since she has always wanted to love someone named Ernest. Jack asks if she would still love him if his name were not Ernest. She would not, she maintains. He proposes to her, and she accepts. Lady Bracknell comes in, and Gwendolen informs her of their engagement. Lady Bracknell says that only she or her father can engage Gwendolen, and orders her to wait in the carriage. After she leaves, Lady Bracknell learns from Jack that he was an orphan, found in a handbag on a train. She is aghast and says she will not allow her daughter to marry him. She leaves and Algernon enters.
Jack tells Algernon what happened, and promises to "kill off" his brother Ernest later in the week. Algernon expresses interest in meeting Cecily, but Jack does not want this to happen, as she is young and pretty. Gwendolen returns. She tells Algernon to turn his back. She asks Jack his address in the country, and Algernon slyly writes this down and checks a train timetable. Gwendolen promises to write Jack daily when he returns to the countryside, and Jack escorts her out. Algernon informs Lane that he will be going Bunburying tomorrow.
In the garden at Jack's country house, Miss Prism and Cecily discuss Jack's seemingly serious demeanor; Miss Prism believes it is due to his anxiety over his reckless brother. Dr. Chasuble enters the garden. He and Miss Prism leave for a walk together. Merriman, their butler, announces the arrival of Ernest Worthing. Algernon enters, pretending to be Ernest. He and Cecily briefly discuss his "wicked" reputation. When he learns that Jack will be back Monday afternoon, Algernon announces that he must leave Monday morning. He flirts with Cecily and they exit into the house.
Miss Prism and Chasuble return. She urges him to get married to a mature lady. Jack enters the garden, dressed in black. He tells Miss Prism he has returned earlier than expected, and explains that he is dressed in black for his brother, who died in Paris last night. Jack asks Chasuble if he would christen him this afternoon. He agrees, and Cecily emerges from the house. She tells him that his brother is in the dining room; Jack says he doesn't have a brother. She runs into the house and brings out Algernon. Jack refuses to shake Algernon's hand, but Cecily says that "Ernest" has been telling him about his friend Bunbury, and that someone who takes care of an invalid must have some good in him. Everyone but Jack and Algernon leaves. Jack orders Merriman to get the dogcart, as Ernest has been called back to town (he wants to get rid of Algernon). Jack tells Algernon he must leave, while Algernon expresses an interest in Cecily. Jack exits.
Cecily enters the garden. Merriman tells Algernon that the dogcart is ready, but Cecily says it can wait. Algernon compliments Cecily to her great delight. She then tells Merriman that the dogcart can come back next week. He asks Cecily to marry him, and she points out that they have been engaged for three months. "Ever since [she] heard of Jack's wicked brother Ernest" she has loved him. Cecily shows him the box of letters he "wrote" to her (which she really wrote to herself). She also admits that she loves him because his name is Ernest. Upon promptin, she doubts she would be able to love him were his name Algernon. He says he needs to see Chasuble quickly about "christening...I mean on most important business." Algernon exits.
Merriman announces that Gwendolen has asked to see Mr. Worthing (Jack). Cecily informs him that he has gone off to see Chasuble some time ago, but invites her in. Gwendolen immediately takes to Cecily, but wishes Cecily were not so young and alluring, as "Ernest," despite his moral nature, is still susceptible to temptation. Cecily tells her that she is not Ernest's ward, but his brother Jack's. Rather, she is going to marry Ernest. They compare diary entries. Gwendolen feels she has the prior claim, since Ernest asked to marry her yesterday. The girls argue and insult each other.
Jack enters the garden, and Gwendolen asks if he is engaged to Cecily; he laughs and denies it. Cecily says the man before them is her Uncle Jack. As Gwendolen goes into shock, Algernon enters, and Cecily calls him Ernest. She asks if he is married to Gwendolen; he denies it. Gwendolen says that his name is Algernon. Cecily is shocked, and she and Gwendolen hold each other and make up. Jack confesses he has no brother Ernest, nor any brother at all. The women retire to the house. Jack is angry at Algernon for stirring up trouble with his Bunburying. They have both arranged for Chasuble to christen them "Ernest" later that evening. Jack tells Algernon to go, but he refuses.
Jack and Algernon join Gwendolen and Cecily inside the country house. The women tell the men their "Christian names are still an insuperable barrier." The men reveal that they are to be re-christened this afternoon, and the couples hug. Lady Bracknell arrives, and Gwendolen informs her of her engagement. Lady Bracknell tells Jack that he may not speak any more to her daughter.
Jack introduces Cecily to Lady Bracknell, and Algernon says that he is engaged to her. Only when Lady Bracknell discovers Cecily has a large personal fortune does she give her consent for their marriage. However, Jack claims that, as his ward, Cecily may not marry without his consent until age 35. He declines to give the necessary consent. He says that he suspects Algernon of being untruthful. He recounts this afternoon's events, in which Algernon impersonated Jack's brother. Jack tells Lady Bracknell that if she consents to his marriage with Gwendolen, he will consent to Cecily's with Algernon. Lady Bracknell refuses and tells Gwendolen to get ready for the train.
Chasuble enters and announces that he is prepared for the christenings. Lady Bracknell refuses to allow Algernon to be baptized, and Jack tells Chasuble that the christenings will not be necessary any more. Chasuble says he will leave, and mentions that Miss Prism is waiting for him. Lady Bracknell asks to see Miss Prism. When she enters, she goes pale upon seeing Lady Bracknell, who accuses her of kidnapping a baby boy from her house 28 years ago. Under Jack's questioning, Miss Prism reveals that she accidentally left the baby in a handbag on the Brighton railway line. Jack leaves excitedly.
Jack returns with this very handbag. Jack tells her he was the baby. Lady Bracknell informs Jack that he is the son of her sister, making him Algernon's older brother. Jack asks Lady Bracknell what his original name was. She says he was named after his father; after locating his name under the Army Lists, they learn his full name is Ernest John Moncrieff. All three couples, Chasuble and Miss Prism, Algernon and Cecily, and Jack and Gwendolen, embrace. Jack tells Lady Bracknell that he has realized, for the first time in his life, "the vital Importance of Being Earnest."