When Ahaziah's mother, Athaliah, saw that her son was dead, she killed all the royal family.
But Jehosheba, King Jehoram's daughter and Ahaziah's sister, took Joash, Ahaziah's son. She stole him from among the other sons of the king who were about to be murdered. She put Joash and his nurse in a bedroom to hide him from Athaliah, so he was not killed.
He hid with her in the Temple of the Lord for six years. During that time Athaliah ruled the land.
In the seventh year Jehoiada sent for the commanders of groups of a hundred men, as well as the Carites. He brought them together in the Temple of the Lord and made an agreement with them. There, in the Temple of the Lord, he made them promise loyalty, and then he showed them the king's son.
He commanded them, "This is what you must do. A third of you who go on duty on the Sabbath will guard the king's palace.
A third of you will be at the Sur Gate, and another third will be at the gate behind the guard. This way you will guard the Temple.
The two groups who go off duty on the Sabbath must protect the Temple of the Lord for the king.
All of you must stand around the king, each man with his weapons in his hand. If anyone comes near, kill him. Stay close to the king when he goes out and when he comes in."
The commanders over a hundred men obeyed everything Jehoiada the priest had commanded. Each one took his men who came on duty on the Sabbath and those who went off duty on the Sabbath, and they came to Jehoiada the priest.
He gave the commanders the spears and shields that had belonged to King David and that were kept in the Temple of the Lord.
Then each guard took his place with his weapons in his hand. There were guards from the south side of the Temple to the north side. They stood by the altar and the Temple and around the king.
Jehoiada brought out the king's son and put the crown on him and gave him a copy of the agreement. They appointed him king and poured olive oil on him. Then they clapped their hands and said, "Long live the king!"
When Athaliah heard the noise of the guards and the people, she went to them at the Temple of the Lord.
She looked, and there was the king, standing by the pillar, as the custom was. The officers and trumpeters were standing beside him, and all the people of the land were very happy and were blowing trumpets. Then Athaliah tore her clothes and screamed, "Traitors! Traitors!"
Jehoiada the priest gave orders to the commanders of a hundred men, who led the army. He said, "Surround her with soldiers and kill with a sword anyone who follows her." He commanded this because he had said, "Don't put Athaliah to death in the Temple of the Lord."
So they caught her when she came to the horses' entrance near the palace. There she was put to death.
Then Jehoiada made an agreement between the Lord and the king and the people that they would be the Lord's special people. He also made an agreement between the king and the people.
All the people of the land went to the temple of Baal and tore it down, smashing the altars and idols. They also killed Mattan, the priest of Baal, in front of the altars. Then Jehoiada the priest placed guards at the Temple of the Lord.
He took with him the commanders of a hundred men and the Carites, the royal bodyguards, as well as the guards and all the people of the land. Together they took the king out of the Temple of the Lord and went into the palace through the gate of the guards. Then the king sat on the royal throne.
So all the people of the land were very happy, and Jerusalem had peace, because Athaliah had been put to death with the sword at the palace.
Joash was seven years old when he became king.