
Ahithophel seems to be--almost--a mixed character. He is wise, which would intimate godly, especially when his counsel is said to be as the very words of God, and his betrayal of David is a just betrayal, if such a thing exists, in light of the offense done to him by David. He is also a parallel to Judas, as will be shown a bit more later on.
To begin with, Uriah was one of David's mighty men, and his wife was Ahithophel's granddaughter (2 Samuel 11:3, 23:24, 23:39, 1 Chronicles 11:41). (On a side note that I may pursue later, the fact that Uriah's home could be seen from the palace suggests that the most loyal/mighty men were given homes surrounding the palace in which the king dwelled, which could possibly mirror the guard of the Tabernacle in which God dwelt, Num. 3:38 among others. And anyone that doesn't immediately embrace this is a heretic.) Due to the wisdom of Ahithophel and the public nature of David's sin (2 Samuel 12:14), there is no conceivable way that Ahithophel was not aware of what David had done, and no doubt had some feelings about it that could be described as "less than ecstatic." His granddaughter's husband, a very prominent, noble and godly man, was murdered, and his granddaughter was getting married to the murderer.
So, when Absalom rebelled, how would that look to a wise man who was well acquainted with the justice of God, and had explicit and personal knowledge of David's gross sin? Obviously, God had judged David unfit to be king, and was replacing him. After all, David's decline, which is brutally marked, began with Bathsheba. He is never again portrayed in a kingly fashion. His weakness is what is noted, his lack of leadership, his lack of strength, his lack of initiative, his lack of knowledge of the affairs of his kingdom, his lack of foresight, even his lack of sexual interest, in bitter irony: through grasping for sex he loses his taste for sex (which is a pattern of God's judgment: we follow an evil desire with an evil action, and God lets us, but our judgment is the natural result of that action). Or, should we wish a less favorable light for Ahithophel, when Absalom rebelled, Ahithophel had the only chance he would ever get for revenge.
In either case, he betrayed David (who had horrifically betrayed him), and aimed to kill him with counsel: blood for blood. As a result of betraying God's anointed, he is overthrown and chooses to kill himself. This draws an illuminating parallel to Judas, which gives us a new angle on the well-known story of Judas' betrayal, as shown in the next post.