In 1891 Wilde began an intimate friendship with Lord Alfred Douglas, a young, vain aristocrat. As the two grew closer, family and friends on both sides urged Wilde and Douglas to lessen their contact. Lord Alfred's father, the Marquess of Queensberry, often feuded with his son over the topic. Especially after the suicide death of his eldest son, the Viscount Drumlanrig, Queensberry privately accused them of improper acts and threatened to cut off Lord Alfred's allowance. When they refused, he began publicly harassing Wilde. In early 1895 Wilde had reached the height of his fame and success with his plays An Ideal Husband and The Importance of Being Earnest on stage in London. When Wilde returned from holidays after the premieres, he found Queensberry's card at his club with the inscription: "For Oscar Wilde, posing somdomite [sic]".[Notes 1]
Unable to bear further insults and encouraged by Lord Alfred (who wanted to attack his father in every possible way), Wilde sued Queensberry for criminal libel. Wilde withdrew his claim as the defence began but the Judge deemed that Queensberry's accusation was justified. The Crown promptly issued a warrant for his arrest and he was charged with gross indecency with other men under the Labouchere Amendment in April 1895. The trial was the centre of public discussion as details of Wilde's consorts from the working class became known. Wilde refused to admit wrongdoing and the jury were unable to reach a verdict. At the retrial Wilde was sentenced to two years' imprisonment, to be held to hard labour.
He was imprisoned in Pentonville, Wandsworth, and Reading Prisons, where the poor food, manual labour, and harsh conditions greatly weakened his health. He quickly began suffering from hunger, insomnia, and disease. He was visited in Pentonville by R.B.S Haldane, a liberal, reforming MP whom he had known before. Haldane championed his case and arranged for access to religious, educational, and historical books. Whilst in Wandsworth Wilde collapsed in the Chapel and burst his right ear drum, an injury that would later contribute to his death. He spent two months recovering in the infirmary. Friends arranged for him to be transferred to Reading Prison, where he was prescribed lighter duties and allowed to spend some time reading but not writing. Depressed, he was unable to complete even these duties, and under Colonel Isaacson, the strict Warden of Reading Prison, Wilde became trapped in a series of harsh punishments for trivial offences. The failure to complete them led to renewed sanction.
Wilde, who still loved Lord Alfred, became upset as contact from him became rare, then annoyed when he learned that the latter planned to publish Wilde's letters without permission and dedicate poems to him unasked. He wrote to friends immediately, forbidding the former and refusing the latter. Wilde still maintained his belief that the Queensberrys owed him a debt of honour arising from his bankruptcy trial.
Wilde's friends continued pressing for better conditions and, in 1897, Major Nelson, a man of a more progressive mind, replaced Col. Isaacson as Warden. He quickly visited Wilde and offered him a book from his personal library, the sympathy bringing Wilde to tears. Soon Wilde requested lists of books, returning to Ancient Greek poets and Christian theology, and studying modern Italian and German, though it was Dante's Inferno that held his attention.
Wilde was granted official permission to have writing materials in early 1897, but even then under strict control: he could write to his friends and his solicitor, but only one page at a time. Wilde decided to write a letter to Douglas, and in it discuss the last five years they had spent together, creating an autobiography of sorts. Wilde spent January, February, and March 1897 writing his letter. Textual analysis of the manuscript shows that Nelson probably relaxed the stringent rules, allowing Wilde to see the papers together: three of the sheets are of relatively fair copy, suggesting they were entirely re-written, and most do not end with a full-stop. Wilde requested that he might send the letter to Lord Alfred Douglas or Robert Ross, which the Home Office denied, but he was permitted to take it with him on release. Wilde never revised the work after he left prison.