Some Arabs had led a raid and killed all of King Jehoram's sons except Ahaziah, the youngest. So now the people of Jerusalem made Ahaziah king as his father's successor.
Ahaziah became king at the age of twenty-two, and he ruled in Jerusalem for one year. Ahaziah also followed the example of King Ahab's family, since his mother Athaliah - the daughter of King Ahab and granddaughter of King Omri of Israel - gave him advice that led him into evil.
References for 2 Chronicles 22:2
He sinned against the Lord, because after his father's death other members of King Ahab's family became his advisers, and they led to his downfall.
Following their advice, he joined King Joram of Israel in a war against King Hazael of Syria. The armies clashed at Ramoth in Gilead, and Joram was wounded in battle.
He returned to the city of Jezreel to recover from his wounds, and Ahaziah went there to visit him.
God used this visit to Joram to bring about Ahaziah's downfall. While Ahaziah was there, he and Joram were confronted by a man named Jehu son of Nimshi, whom the Lord had chosen to destroy the dynasty of Ahab.
As Jehu was carrying out God's sentence on the dynasty, he came across a group made up of Judean leaders and of Ahaziah's nephews that had accompanied Ahaziah on his visit. Jehu killed them all.
A search was made for Ahaziah, and he was found hiding in Samaria. They took him to Jehu and put him to death. But they did bury his body out of respect for his grandfather King Jehoshaphat, who had done all he could to serve the Lord. No member of Ahaziah's family was left who could rule the kingdom.
As soon as King Ahaziah's mother Athaliah learned of her son's murder, she gave orders for all the members of the royal family of Judah to be killed.
Ahaziah had a half sister, Jehosheba, who was married to a priest named Jehoiada. She secretly rescued one of Ahaziah's sons, Joash, took him away from the other princes who were about to be murdered and hid him and a nurse in a bedroom at the Temple. By keeping him hidden, she saved him from death at the hands of Athaliah.
For six years he remained there in hiding, while Athaliah ruled as queen.