In writing the novel, Montgomery was inspired by notes she had made as a young girl, about a couple who were mistakenly sent an orphan girl instead of the boy they had requested yet decided to keep her. She drew upon her own childhood experiences in rural Prince Edward Island. Montgomery used a photograph of Evelyn Nesbit as the model for the face of Anne Shirley, which she had clipped from New York’s Metropolitan Magazine and put on the wall of her bedroom.
Montgomery was also inspired by the "formula Ann" orphan stories which were popular at the time and distinguished her character by spelling her name as "Anne." She based other characters such as Gilbert Blythe in part on people she knew. She said that she wrote the novel in the twilight of the day, while sitting at her window and overlooking the fields of Cavendish.