I am certain that Jehoshaphat was convinced he was acting righteously when he pledged to join Ahab in war. In fact, Scripture says, "Jehoshaphat said unto the king of Israel, Inquire, I pray thee, at the word of the Lord today" (2 Chronicles 18:4). He said, "Let's ask the Lord for His counsel on the matter. We won't act until we hear from Him!"
God made His word to Jehoshaphat and Ahab clear, leaving no doubt as to what He thought about the whole affair: "It's doomed! Go at your own risk. Nothing but death and defeat await you on the battlefield" (see 2 Chronicles 18:16).
At this point, Jehoshaphat seemed willing to obey a true prophetic word and do everything God told him. Yet, for centuries, Bible scholars have marveled at what happened next: When the clear word came, Jehoshaphat ignored it!
Beloved, you can boast all you want about loving God and wanting to obey Him. But if you do not break away from the deception of ungodly friends and seek Holy Ghost discernment, you will end up ignoring God's Word!
You may accompany your friend in his war but when the chips are down, he will hand you over to the enemy. That's just what happened to Jehoshaphat when he went to war with Ahab. The evil king set up Jehoshaphat to be killed; he told him to dress in his kingly robes, while Ahab himself dressed as a soldier. That way, Ahab reasoned, the enemy would go after Jehoshaphat instead of himself.
Ironically, Ahab was killed by an arrow that pierced him through a tiny slot in his armor. And suddenly, Jehoshaphat was surrounded by enemy soldiers, who were ready to cut him to pieces. The king knew he was facing death and he cried out to God for help. Scripture tells us, "And the Lord helped him; and God moved them to depart from him" (18:31).
The war was a disaster. Israel's army fled in disarray, like sheep without a shepherd. And Jehoshaphat retreated to Jerusalem, his friend Ahab dead and his armies defeated. It was only by God's grace that he escaped death!
I can imagine the thoughts that must have raced through Jehoshaphat's mind as he hurried back to Jerusalem: "Oh, God, thank You for delivering me! Now I see the danger of walking with an ungodly companion. Never again, Lord! I won't be a part of that worldly system anymore. It's all over now!"