In the summer of 1893, Oscar Wilde began writing An Ideal Husband, and he completed it later that winter. His work began at Goring-on-Thames, after which he named the character Lord Goring, and concluded at St. James Place. He initially sent the completed play to the Garrick Theatre, where the manager rejected it, but it was soon accepted by the Haymarket Theatre, where Lewis Waller had temporarily taken control. Waller was an excellent actor and cast himself as Sir Robert Chiltern. The play gave the Haymarket the success it desperately needed.
After opening on 3 January 1895, it continued for 124 performances. In April of that year, Wilde was arrested for "gross indecency" and his name was publicly removed from the play. On 6 April, the same day as Wilde's arrest, the play moved to the Criterion Theatre where it ran from 13–27 April. The play was published in 1899, although Wilde was not listed as the author. This published version differs slightly from the performed play, for Wilde added many passages and cut others. Prominent additions included written stage directions and character descriptions. Wilde was a leader in the effort to make plays accessible to the reading public.