When Mayella is on the stand testifying, Atticus establishes reasonable doubt that Tom is guilty.
When Mayella is on the stand, Atticus treats her with respect. She misinterprets this respect and believes that he is mocking her. However, he is able to prove that she has a difficult life and was very lonely, and she was attacked by her father and not Tom Robinson.
Mayella looked from under lowered eyelids at Atticus, but she said to the judge: "Long's he keeps on callin' me ma'am an sayin' Miss Mayella. I don't hafta take his sass, I ain't called upon to take it." (CH 18)
By being polite to Mayella, Atticus establishes how young and unintelligent she really is. She interprets common courtesy as sass, so she has not been the recipient of it before. Atticus goes on to establish that Mayella was more afraid of her father than Tom Robinson, thus trying to establish reasonable doubt that Robinson attacked her.