The story actually gets better as you follow along. We have a queen who is ruling over Judah, in Jerusalem. That is Athaliah, Ahaziah’s mother. Remember Ahaziah was the one who was killed by Jehu as he was running away from him after his father was killed. After Ahaziah was killed then his mother, Athaliah, wanted to secure her throne and so killed all of her family members. She succeeded except for one of Ahaziah’s sons, Joash. He was hidden by one of Ahaziah’s sisters, Jehosheba. I hope you are following. The queen mother wanted to consolidate her power, but her step-daughter hid one of her grandchildren so that he would be spared from the slaughter that took place in order to consolidate the queen mother’s power.
This infant grew and when he was 7 years old the high priest, Jehoiada, commanded the captains of the Carites to join him and make an oath to him. They promised to protect this child, Joash, from anyone who might look to harm him. Jehoiada anoints him in the temple, just like we see Jehu was anointed by a minion and the other kings who were anointed by priests, and the people celebrate the new king, even while the queen mother is trying to consolidate her power.
She comes out of the kings palace wondering what all the commotion is in the temple. When she enters the temple and sees that this new king has been anointed she is arrested and killed outside the temple. The new king then takes his residence in the kings palace when he is only 7 years old. We find that the Lord and His people begin to take back over the land. In Jerusalem we have a high priest who anoints a new king and you can assume that the new king will follow the way of God. In the north you have Jehu who kind of followed God and destroyed all the priests and the people of Baal. Things are starting to look up.