This website has a fantastic write up about Ahithophel as a whole. Many things that I missed in my first reading that went into this story.

Quoted from the site above and abbreviated: “You see Ahitophel was the one person who was in the know when David committed adultery with Bathsheba. He was in the Palace, in the confidence of the King, and he was Bathsheba’s Grandfather! Yes look up 2 Samuel 11:3. Bathsheba was the daughter of Eliam whose father was Ahitophel.

Here is the seed of betrayal that years later became the motivation to turn on David and join Absalom….

…Grandfather Ahitophel carried that grudge for years, and David never knew it. In Psalm 41:9 David laments, “Yea mine own familiar friend in whom I trusted, which did eat of my bread, hath lifted up his heel against me.”…

…When Ahitophel saw that his advice to Absalom to attack David immediately and kill him, was rejected, he knew that David would come out the victor and there was no future for him, so he went home, related the events to his family, and according to Josephus, he went into an inner room, hanged himself, and the family buried him.”

Another good article on the topic: