When Ahaziah's mother, Athaliah, saw that her son was dead, she began to destroy the entire royal family.
But Jehosheba, daughter of King Jehoram and sister of Ahaziah, took Ahaziah's son Joash. She saved him from being killed with the king's other sons, and in a bedroom she hid him and his nurse from Athaliah. So Joash wasn't killed
but was hidden with her in the LORD's temple for six years while Athaliah ruled the country.
In the seventh year of Athaliah's reign, Jehoiada sent for the company commanders of the Carites and the guards and had them come to him in the LORD's temple. He made an agreement with them, put them under oath in the LORD's temple, and showed them the king's son.
He ordered them, "This is what you must do: One third of you, those who are on duty on the day of worship, must guard the royal palace.
Another third must be at Sur Gate. And another third must be at the gate behind the guards. You will guard the king's residence.
Then your two groups who [normally] go off duty on the day of worship must guard the king at the LORD's temple.
Surround the king. Each man should have his weapons in his hand. Kill anyone who tries to break through your ranks. Stay with the king wherever he goes."
The company commanders did as the priest Jehoiada had ordered them. Each commander took his men who were coming on duty on the day of worship as well as those who were about to go off duty and came to the priest Jehoiada.
He gave the commanders the spears and the shields that had belonged to King David but were now in the LORD's temple.
The guards stood with their weapons in their hands. They were stationed around the king and around the altar and the temple (from the south side to the north side of the temple).
Then Jehoiada brought out the king's son, gave him the crown and the religious instructions, and made him king by anointing him. As the guards clapped their hands, they said, "Long live the king!"
When Athaliah heard the noise made by the guards and the other people, she went into the LORD's temple, where the people were.
She looked, and the king was standing by the pillar according to custom. The commanders and the trumpeters were by his side. All the people of the land were rejoicing and blowing trumpets. As Athaliah tore her clothes [in distress], she cried, "Treason, treason!"
Then the priest Jehoiada ordered the company commanders who were in charge of the army, "Take her out of the temple. Use your sword to kill anyone who follows her." (The priest had said, "She must not be killed in the LORD's temple.")
So they arrested her as she came to the street where the horses enter the royal palace, and there she was killed.
Jehoiada made a promise to the LORD on behalf of the king and his people that they would be the LORD's people. He made other promises between the king and the people.
Then all the people of the land went to the temple of Baal and tore it down. They smashed Baal's altars and his statues and killed Mattan, the priest of Baal, in front of the altars. Next, the priest appointed officials to be in charge of the LORD's temple.
He took the company commanders of the Carites and the guards and all the people of the land, and they brought the king from the LORD's temple. They went down the street that goes through Guards' Gate to the royal palace. Then Joash sat on the royal throne.
All the people of the land were celebrating. But the city was quiet because they had killed Athaliah with a sword at the royal palace.
Joash was seven years old when he began to rule.