In Algernon Moncrieff's London flat, two idle gentlemen compare the fictions they live by. Jack Worthing has been Ernest in town and Jack in the country, using an invented wayward brother named Ernest as his excuse to leave his country estate and his young ward Cecily. Algernon, who calls the practice Bunburying after his own imaginary invalid friend Bunbury, recognizes a fellow escape artist and demands to be told the rules.
Jack means to propose to Algernon's cousin Gwendolen Fairfax, and she accepts, but warns that her whole ideal has been to love a man called Ernest, a name she finds full of confidence and vibrations. Her mother, Lady Bracknell, interviews Jack as a marriage candidate and is undone by his answer that he was found, as a baby, in a hand-bag at Victoria Station. She forbids the match until he can produce at least one respectable parent.
At Jack's country house the two fictions tangle. Algernon arrives uninvited, posing as the wicked brother Ernest to court Cecily, who, it emerges, has already conducted an entire imaginary engagement to that very Ernest in her diary. When Gwendolen visits and meets Cecily, each believes she is betrothed to the same Ernest, and a fierce, exquisitely polite quarrel breaks out over tea before the men are exposed as neither named Ernest nor brothers at all.
Throughout, Wilde keeps the social hierarchy of values upside down. The characters are deadly serious about cucumber sandwiches, the cut of a name, and the contents of a diary, and breezily flippant about truth, sincerity, baptism, and death. The epigrams do the satirical work, treating earnestness, the Victorian cult of being grave and high-minded, as the most fashionable of all the poses on display.
The knots are untied by coincidence rather than reform. Cecily's old governess Miss Prism is revealed to have absent-mindedly left a baby in a hand-bag years before, making Jack the long-lost elder son of Lady Bracknell's sister and Algernon's actual brother. His real name, by the army lists, turns out to be Ernest John. Jack embraces Gwendolen and declares he has at last grasped the vital importance of being earnest, the pun sealing a comedy in which the saving truth was a name.