When Joram had ruled twelve years over Israel, Ahaziah the son of Jehoram began to rule over Judah. And he went down to Jezreel to visit Joram, who was ill. When Jehu struck down Joram, Ahaziah saw it and fled toward Beth-gannim. But Jehu followed after him with the words, "Shoot him down, too, in the chariot." So they shot him down on the way up to Gur, near Ibleam, but he escaped to Megiddo and died there.
When Athaliah, the mother of Ahaziah, learned that her son was dead, she rose and put to death all of Ahaziah's children except Joash, whom his aunt, Jehosheba, secretly took and placed with his nurse in the bedchamber. In this way she hid him from Athaliah, so that he was not put to death. He was with her, hid in the temple of the LORD, six years, while Athaliah ruled over the land.
But in the seventh year Jehoiada the priest called together the officers of the royal guard and brought them into the temple of the LORD. After he had made them make a solemn promise, he showed them Ahaziah's son, and gave them these orders, "This is what you shall do: a third part of you who go in on the sabbath to guard the palace shall keep watch over it. Two divisions of you, including all who go out on the Sabbath to guard the temple of the LORD, shall surround Joash, each with his weapons in his hand. And let every one who comes within the ranks be put to death. Thus you shall guard Joash, when he goes out and when he comes in."
The officers did as Jehoiada the priest commanded. And he brought out Ahaziah's son and put the crown and the royal ornaments upon him; and they made him ruler over Judah and poured oil upon his head and clapped their hands, crying, "Long live the ruler!"
But when Athaliah heard the people shouting, she came to them in the temple of the LORD. When she saw Joash standing by the pillar, as was the custom, and the officers and the trumpeters by him, and all the people of the land rejoicing and blowing trumpets, she tore her clothes and cried, "Treason! Treason!" But Jehoiada the priest gave this order to the officers: "Bring her out between the ranks, and kill with the sword whoever follows her," for the priest said, "Let her not be put to death in the temple of the LORD." So they seized her, and she was killed as she went through the horses' entry to the palace.
Jehoiada made a solemn agreement between the LORD and the new ruler and the people, that they should be the LORD's people; also between the ruler and the people, and Joash ruled forty years in Jerusalem.