John openly admits that he has had an affair with Abigail.
At this point in the play, Abigail is in full control of the the girls and the proceedings of the court. The judges believe that Abigail is as pure as the driven snow. In order for John to save his wife and his friends from execution, John needs a way to discredit Abigail. Unfortunately, John's best evidence against her will also ruin his name and reputation. By admitting that he had sex with Abigail, John can show the court that Abigail is not to be trusted. He even calls her a "whore":
Proctor, breathless and in agony: It is a whore!
Danforth, dumfounded: You charge - ?
Abigail: Mr. Danforth, he is lying!
John's accusation isn't enough. Danforth demands proof, and John freely admits that he had sex with Abigail in his barn.
Danforth: You will prove this! This will not pass!
Proctor, trembling, his life collapsing about him: I have known her, sir. I have known her. . .
Danforth, dumfounded: In - in what time? In what place?
Proctor, his voice about to break, and his shame great: In the proper place - where my beasts are bedded. On the last night of my joy, some eight months past.
After John admits this, Danforth is much more suspicious of Abigail, but he still requires further evidence to corroborate John's story. He calls for Elizabeth to come into the court in order to ask her about the relationship. John tells Danforth that his wife will back up his story because she never lies. All Elizabeth has to do to save herself and John is to tell the truth. Unfortunately, Elizabeth lies about the affair. She doesn't know that John already admitted to it, and she believes that her lie will protect her husband.
Danforth: Answer my question! Is your husband a lecher!
Elizabeth, faintly: No, sir.
Danforth: Remove her, Marshal.
Proctor: Elizabeth, tell the truth!
Danforth: She has spoken. Remove her!
Proctor, crying out: Elizabeth, I have confessed it!
Elizabeth: Oh, God! The door closes behind her.
Proctor: She only thought to save my name!
Because of Elizabeth's lie, Proctor is now considered a liar and enemy of the court, and Abigail is once again believed.