Let’s remind ourselves that Athaliah was the daughter of Ahab and Jezebel; she married Jehoram of Judah. During his reign, he gave his wife way too much authority, allowing her to weaken the Temple services to Jehovah. Eventually she had a shrine to Baal built on the Temple plaza (but apparently not inside the Temple grounds itself). While standard annual feasts of the Covenant were kept, a great many priests and Levites were pushed out of active service, and Temple offerings declined dramatically.
All of this sin led to God punishing Jehoram, allowing Edom to break the yoke, and some foreign invasion forces to plunder the palace. They also took as hostages all but the youngest son, Ahaziah. Then Jehoram died of a horrifying ailment that saw his intestines extrude out of his body, so it was an agonizing death. Ahaziah was king a very short time and was killed when Jehu rebelled against the King of Israel to the north. Then Jehu slaughtered all the adult men from the royal family of Judah as they traveled to visit their kinfolks at the Jezreel palace.
When Athaliah learned of all this, she finished off the other royal children too young to travel like that. Of course, this was actually at the hands of her royal bodyguard, who by tradition were essentially Philistines loyal to David’s royal household, who would have had no interest in the politics of the kingdom. It’s unlikely she would see the need to witness their grisly task. One of her grandsons escaped this slaughter. Her son Ahaziah had a sister; we believe she was a half-sister born from one of Jehoram’s concubines — Jehosheba. She was married to the High Priest, Jehoiada.
It’s easy to see how Jehosheba would be a partisan in favor of the true worship of Jehovah, and not at all pleased with Athaliah’s plans to convert Judah to the worship of Baal, as her mother Jezebel tried to do in Israel. So Jehosheba grabbed the infant son of Ahaziah, a child named Joash (AKA Jehoash). The lady hid him from the slaughtering soldiers in one of the bedrooms with his wet nurse. Later, she smuggled him out of the palace alive and took him to the Temple. Her husband as High Priest managed to hide the boy in the Temple grounds and raise him to serve Jehovah.
At this time, we are pretty sure the wider Temple plaza was at last a full story higher in elevation than the palace. The Temple courts would have been yet another level higher than most of the plaza. Solomon put walls of varying heights around the different courts — Court of Gentiles, Court of Women, Court of Israel. However, all of them were taller than humans. With no interest in the Temple services, Athaliah would have relied on spies to keep a watch over things in the Temple. Apparently they weren’t very effective. She knew nothing about Joash.
So after six or so years of Athaliah forcing Baal worship down everyone’s throat in Judah, it was time for the High Priest to act. Jehoiada commissioned the head of the Temple Guard (they were all Levites trained as professional soldiers) to recall the Levites, especially the entire Temple Guard force who were home on off-season rotation. They assembled in a secret meeting at the Temple, and the High Priest introduced them to Joash. They took an oath on their commitment to Jehovah to carry out his plans to raise up Joash as the King of Judah.
We don’t really know the exact layout of Temple Plaza and palace, but here’s what we believe the text is telling us. The normal rotation of guards for the Sabbath duty were divided into three groups. One group guarded the palace doorway closest to the Temple. A second group guarded the matching south entrance to the Temple grounds. The third group was at another gate nearby. These would defend the Temple grounds from anyone who might interfere with the coronation.
The rest who would normally be off rotation would be stationed in a tight arc just in front of the steps leading up from the Court of Israel to the raised porch and Temple entrance. No one was to be allowed past them once Jehoida set things in motion. They would remain as the young King’s bodyguard until further notice. Then the High Priest passed out to them the heavier lances and shields David had placed in care of the Temple. This would make them a very formidable force, more than a match for anything Athaliah could command. Normal guard duty required only a short sword and leather armor, and this was all the royal bodyguard would have had.
At the appropriate moment, Jehoiada brought out the boy Joash and stood him by one of the two huge bronze pillars standing at the front of the Temple. One was designated for the vesting of High Priests, the other for the Kings. Joash stood by the latter pillar and was crowned, then handed a copy of the Covenant. He was anointed King and Jehoiada led a chant and cheer for him, proclaiming him the rightful King of Judah.
The crowd was made up of those still faithful to the Covenant, so naturally they cheered quite loudly, celebrating the end of Athaliah’s immoral oppression. She hated the worship of Jehovah and was probably sitting in the throne room when she heard the loud cheering in the Temple. With her bodyguard in tow, she ran to the Temple gate and saw what was happening. She knew exactly what it meant, and cried “Treason!” It was supposed to be a signal for her bodyguard to attack, but they were far outnumbered and out-gunned, so to speak.
So when Jehoiada commanded his forces near the gate to take her in custody, you can bet the bodyguard surrendered or were taken with her. The High Priest wanted to ensure she didn’t bleed on the Temple grounds and defile things, so he had her marched to the Horse Gate, somewhere along the eastern wall of the city, between the palace and the old fortress of David. They struck her down there, along with anyone who was loyal to her.
While that bunch were marching off, Jehoiada led another ceremony, renewing the Covenant with the King, himself and the the tribal elders on hand. He stressed the various obligations of each party before Jehovah. Once it was clear what he meant, the elders led the crowd to the shrine of Baal there on the Temple plaza. They tore it all down, destroyed the images and furnishings, and killed the pagan priest there.
Meanwhile, Jehoiada reasserted the Temple services to their former grandeur. All the priests and Levites who had been run out of town were enrolled once more in a fully attended rotation. Everyone fit to serve was appointed a duty in the Temple during some part of the year. This included a much higher count of Temple guards to serve as the King’s bodyguard until things could get back to normal.
So they escorted the boy king down to the palace and went through the ritual of placing him on the throne. You can be sure they would have immediately reorganized the palace staff began getting rid of anyone who didn’t swear formal allegiance to the King.