Although it pains him greatly to do so, Proctor admits to having an adulterous affair with Abigail Williams. Whether or not he went to court ready to make this confession is not certain, but once Proctor sees that Abigail has gained control once again of the court, that the judges do not believe Mary Warren's testimony, and that the petition signed by numerous members of the community on behalf of his wife carries no weight, John is forced to admit to the affair in order to spare his friends' wives' lives. Elizabeth is safe for now because of her pregnancy, but John cannot allow his friends to be executed while he withholds information that might save them.
When John calls Abigail a whore, he knows that he must provide proof, and so he finally lays his soul bare before the judges, knowing that at the least he could be imprisoned for his adulterous relationship or at the worst executed.
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.