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 to be killed.
Only Ahaziah's son Joash escaped. He was about to be killed with the others, but was rescued by his aunt Jehosheba, who was King Jehoram's daughter and Ahaziah's half sister. She took him and his nurse into a bedroom in the Temple and hid him from Athaliah, so that he was not killed.
For six years Jehosheba took care of the boy and kept him hidden in the Temple, while Athaliah ruled as queen.
But in the seventh year Jehoiada the priest sent for the officers in charge of the royal bodyguard and of the palace guards, and told them to come to the Temple, where he made them agree under oath to what he planned to do. He showed them King Ahaziah's son Joash
and gave them the following orders: "When you come on duty on the Sabbath, one third of you are to guard the palace;
another third are to stand guard at the Sur Gate, and the other third are to stand guard at the gate behind the other guards.
References for 2 Kings 11:6
The two groups that go off duty on the Sabbath are to stand guard at the Temple to protect the king.
You are to guard King Joash with drawn swords and stay with him wherever he goes. Anyone who comes near you is to be killed."
The officers obeyed Jehoiada's instructions and brought their men to him - those going off duty on the Sabbath and those going on duty.
He gave the officers the spears and shields that had belonged to King David and had been kept in the Temple,
References for 2 Kings 11:10
and he stationed the men with drawn swords all around the front of the Temple, to protect the king.
Then Jehoiada led Joash out, placed the crown on his head, and gave him a copy of the laws governing kingship. Then Joash was anointed and proclaimed king. The people clapped their hands and shouted, "Long live the king!"
Queen Athaliah heard the noise being made by the guards and the people, so she hurried to the Temple, where the crowd had gathered.
There she saw the new king standing by the column at the entrance of the Temple, as was the custom. He was surrounded by the officers and the trumpeters, and the people were all shouting joyfully and blowing trumpets. Athaliah tore her clothes in distress and shouted, "Treason! Treason!" 1
References for 2 Kings 11:14
Jehoiada did not want Athaliah killed in the Temple area, so he ordered the army officers: "Take her out between the rows of guards, and kill anyone who tries to rescue her."
They seized her, took her to the palace, and there at the Horse Gate they killed her.
The priest Jehoiada had King Joash and the people make a covenant with the Lord that they would be the Lord's people; he also made a covenant between the king and the people.
Then the people went to the temple of Baal and tore it down; they smashed the altars and the idols, and killed Mattan, the priest of Baal, in front of the altars. Jehoiada put guards on duty at the Temple,
and then he, the officers, the royal bodyguard, and the palace guards escorted the king from the Temple to the palace, followed by all the people. Joash entered by the Guard Gate and took his place on the throne.
All the people were filled with happiness, and the city was quiet, now that Athaliah had been killed in the palace.
Joash became king of Judah at the age of seven.