When Athaliah, the mother of King Ahaziah of Judah, learned that her son was dead, she set out to destroy the rest of the royal family.
But Ahaziah's sister Jehosheba, the daughter of King Jehoram, took Ahaziah's infant son, Joash, and stole him away from among the rest of the king's children, who were about to be killed. Jehosheba put Joash and his nurse in a bedroom to hide him from Athaliah, so the child was not murdered.
References for 2 Kings 11:2
Joash and his nurse remained hidden in the Temple of the LORD for six years while Athaliah ruled over the land.
In the seventh year of Athaliah's reign, Jehoiada the priest summoned the commanders, the Carite mercenaries, and the guards to come to the Temple of the LORD. He made a pact with them and made them swear an oath of loyalty there in the LORD's Temple; then he showed them the king's son.
Jehoiada told them, "This is what you must do. A third of you who are on duty on the Sabbath are to guard the royal palace itself.
Another third of you are to stand guard at the Sur Gate. And the final third must stand guard behind the palace guard. These three groups will all guard the palace.
The other two units who are off duty on the Sabbath must stand guard for the king at the LORD's Temple.
Form a bodyguard for the king and keep your weapons in hand. Any unauthorized person who approaches you must be killed. Stay right beside the king at all times."
So the commanders did everything just as Jehoiada the priest ordered. The commanders took charge of the men reporting for duty that Sabbath, as well as those who were going off duty. They brought them all to Jehoiada the priest,
and he supplied them with the spears and shields that had once belonged to King David and were stored in the Temple of the LORD.
The guards stationed themselves around the king, with their weapons ready. They formed a line from the south side of the Temple around to the north side and all around the altar.
Then Jehoiada brought out Joash, the king's son, and placed the crown on his head. He presented Joash with a copy of God's covenant and proclaimed him king. They anointed him, and all the people clapped their hands and shouted, "Long live the king!"
When Athaliah heard all the noise made by the guards and the people, she hurried to the LORD's Temple to see what was happening.
And she saw the newly crowned king standing in his place of authority by the pillar, as was the custom at times of coronation. The officers and trumpeters were surrounding him, and people from all over the land were rejoicing and blowing trumpets. When Athaliah saw all this, she tore her clothes in despair and shouted, "Treason! Treason!"
Then Jehoiada the priest ordered the commanders who were in charge of the troops, "Take her out of the Temple, and kill anyone who tries to rescue her. Do not kill her here in the Temple of the LORD."
So they seized her and led her out to the gate where horses enter the palace grounds, and she was killed there.
Then Jehoiada made a covenant between the LORD and the king and the people that they would be the LORD's people. He also made a covenant between the king and the people.
And all the people of the land went over to the temple of Baal and tore it down. They demolished the altars and smashed the idols to pieces, and they killed Mattan the priest of Baal in front of the altars.Jehoiada the priest stationed guards at the Temple of the LORD.
Then the commanders, the Carite mercenaries, the guards, and all the people of the land escorted the king from the Temple of the LORD. They went through the gate of the guards and into the palace, and the king took his seat on the royal throne.
So all the people of the land rejoiced, and the city was peaceful because Athaliah had been killed at the king's palace.
Joash was seven years old when he became king.
References for 2 Kings 11:21