When Athaliah, Ahaziah’s mother, saw he was dead, she saw her chance to consolidate her own power and become queen. She murdered all of her grandkids as well as all of her late husband’s other male children–except for the infant Joash, whose sister Jehosheba smuggled him out of the palace and hid him in the home of the high priest Jehoida.
When Joash was 7, Jehoida conspired with all the soldiers. He had them guard the boy at the Temple and crowned him king. Then he had the soldiers kill Athaliah and all her followers. He also roused the people to rise up and destroy all the temples of Baal and murder Mattan, high priest of Baal.