The play opens in London, where Algernon Moncrieff discovers that his friend John Worthing leads a double life. John pretends to be a responsible country magistrate named Jack, but adopts the name Ernest when visiting town to enjoy himself. Algernon admits to his own deception, having invented a sickly fictional friend named Bunbury to escape tedious social duties whenever he pleases. John intends to propose to Algernon's cousin, Gwendolen Fairfax, who declares that she can only love a man named Ernest.
Complications multiply when Algernon travels to John's country estate, poses as the wicked fictitious brother Ernest, and promptly falls in love with John's young ward, Cecily Cardew. Cecily reveals that she has already imagined an entire romance and engagement with Ernest. When Gwendolen arrives at the country house independently, both women discover they believe they are engaged to the same man.
They eventually discover the deception, uniting in their indignation against the two men until the truth comes to light. The central mystery is resolved when Lady Bracknell identifies John as her long-lost nephew and Algernon's older brother. It turns out John was mistakenly abandoned in a handbag at a railway station by his governess, Miss Prism, as an infant. Through military records, John learns his actual birth name is indeed Ernest, happily satisfying the romantic ideals of both Gwendolen and Cecily while finally revealing the profound importance of being earnest.