1 Kings 22:53

For he served Baal, and worshipped him, and provoked to anger the LORD God of Israel, according to all that his father had done.

Ahaziah served Baal and worshiped him, continuing in the idolatrous rebellion of his father Ahab and provoking the Lord God of Israel to anger according to all that his father had done. He had witnessed God's mighty acts and the judgments that fell upon apostate Israel, including the fearful end of his own father, yet he treated these warnings as though they were idle tales. Instead of humbling himself before God, he persisted in Baal worship.

That persistence led him on to commit a grave act of impiety. His rebellion was followed by divine judgments that attested to God's wrath against him. Among them was an accident that threatened his life. Judgment also came through war with Moab.