When Athaliah the mother of Ahaziah saw that her son was dead, she proceeded to annihilate all the royal heirs.
Athaliah, Ahab and Jezebel's own daughter, answers her son's death by moving immediately against the rest of David's royal family, determined that no rival claimant survives to threaten the throne she means to take for herself. One child slips through: Jehosheba, a daughter of the royal house and wife of the priest Jehoiada, steals the infant Joash out from among the condemned and hides him with his nurse, keeping him concealed inside the temple itself for six years while Athaliah rules the land unopposed.
Then in the seventh year, Jehoiada sent for the commanders of hundreds, the Carites, and the guards, and had them brought into the house of the LORD. There he made a covenant with them and put them under oath. He showed them the king’s son
When the boy is old enough to be shown safely, Jehoiada moves. He gathers the captains commanding the palace and temple guard, binds them by oath to secrecy, and reveals to them, for the first time, that the rightful king has been alive and growing up in the temple the whole time. He then lays out exactly where each division of the guard is to stand — around the king's own person, at the temple gates, along its approaches — so that every point where danger might break in is covered before the boy is ever brought into public view.
So the commanders of hundreds did everything that Jehoiada the priest had ordered. Each of them took his men— those coming on duty on the Sabbath and those going off duty— and came to Jehoiada the priest.
The captains carry out Jehoiada's plan exactly as instructed, doubling up both the departing and arriving guard divisions rather than letting the changeover thin out the temple's protection at any point. Jehoiada arms them with spears and shields that had belonged to David himself, kept in the temple, and the guard takes its position completely surrounding the altar and the temple building on every side.
Then Jehoiada brought out the king’s son, put the crown on him, presented him with the Testimony, and proclaimed him king. They anointed him, and the people clapped their hands and declared, “Long live the king!”
With every approach secured, Jehoiada brings the boy out at last. The crown, the scroll of the law placed in his hand, the anointing, and the crowd's own acclaim all happen in a single public moment, turning a child who has spent his whole life hidden into Judah's visibly reigning king.
When Athaliah heard the noise from the guards and the people, she went out to the people in the house of the LORD.
The sudden noise draws Athaliah straight to the temple to find out what has happened, and what she finds is the very thing her massacre years earlier was meant to prevent: the boy-king standing in the customary place, crowned and acclaimed, with the whole assembly rejoicing around him. Her cry of treason is aimed at the one true claim to treason in the room — her own.
And Jehoiada the priest ordered the commanders of hundreds in charge of the army, “Bring her out between the ranks, and put to the sword anyone who follows her.” For the priest had said, “She must not be put to death in the house of the LORD.”
Jehoiada orders Athaliah removed from the temple grounds before any sentence is carried out, unwilling to let the sacred space itself be stained even by the killing of a murderous usurper. She is taken out through the horses' entrance to the palace and put to death there, six years of stolen rule ending exactly where her own crimes began.
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.
Before turning to anything else, Jehoiada secures the covenant itself: first between the LORD and the king and the people together, then a second covenant binding king and people to each other under that same standard. The crowd's own response is immediate — they tear down Baal's temple, smash his altars and images, and kill his priest Mattan on the very altars he had served, undoing in an afternoon what years of royal patronage for that worship had built up.
He took with him the commanders of hundreds, the Carites, the guards, and all the people of the land, and they brought the king down from the house of the LORD and entered the king’s house by way of the Gate of the Guards. Then Joash took his seat on the royal throne,
The boy king is escorted in procession from the temple to the palace and takes his seat on the very throne his family nearly lost forever, closing out a story that began with a massacre meant to end it. All the land rejoices, the city settles into quiet now that Athaliah's rule is over, and the chapter closes with the simple fact of how young this restored king actually is.