12 While Absalom was offering sacrifices, he also sent for Ahithophel the Gilonite, David’s counselor, to come from Giloh, his hometown. And so the conspiracy gained strength, and Absalom’s following kept on increasing. 31 Now David had been told, “Ahithophel is among the conspirators with Absalom.” So David prayed, “Lord, turn Ahithophel’s counsel into foolishness.” 32 When David arrived at the summit, where people used to worship God, Hushai the Arkite was there to meet him, his robe torn and dust on his head. 33 David said to him, “If you go with me, you will be a burden to me. 34 But if you return to the city and say to Absalom, ‘Your Majesty, I will be your servant; I was your father’s servant in the past, but now I will be your servant,’ then you can help me by frustrating Ahithophel’s advice. 35 Won’t the priests Zadok and Abiathar be there with you? Tell them anything you hear in the king’s palace. 36 Their two sons, Ahimaaz son of Zadok and Jonathan son of Abiathar, are there with them. Send them to me with anything you hear.” 37 So Hushai, David’s confidant, arrived at Jerusalem as Absalom was entering the city. 2 Samuel 17:1 Moreover Ahithophel said unto Absalom, Let me now choose out twelve thousand men, and I will arise and pursue after David this night: 2 Samuel 17:6 And when Hushai was come to Absalom, Absalom spake unto him, saying, Ahithophel hath spoken after this manner: shall we do after his saying? if not; speak thou. 2 Samuel 17:7 And Hushai said unto Absalom, The counsel that Ahithophel hath given is not good at this time. 2 Samuel 17:14 And Absalom and all the men of Israel said, The counsel of Hushai the Archite is better than the counsel of Ahithophel. For the LORD had appointed to defeat the good counsel of Ahithophel, to the intent that the LORDmight bring evil upon Absalom. 2 Samuel 17:15 Then said Hushai unto Zadok and to Abiathar the priests, Thus and thus did Ahithophel counsel Absalom and the elders of Israel; and thus and thus have I counselled. 2 Samuel 17:21 And it came to pass, after they were departed, that they came up out of the well, and went and told king David, and said unto David, Arise, and pass quickly over the water: for thus hath Ahithophel counselled against you. 2 Samuel 17:23 And when Ahithophel saw that his counsel was not followed, he saddled his ass, and arose, and gat him home to his house, to his city, and put his household in order, and hanged himself, and died, and was buried in the sepulchre of his father.
For follow-up discussion and general commentary on the topic. Comments are sorted chronologically.