The invasion of the Kingdom of Judah by the Aramean army was not a random political event, but a direct consequence of a severe spiritual collapse within the nation's leadership. This critical period began after the death of Jehoiada the High Priest. At that time, King Joash of Judah abandoned the path of the Torah, turned to idol worship, and even declared himself to be a god [רש"י]. These grave sins provoked the anger of God, and as a punishment, He brought Hazael, the king of Aram, against them [מלבי"ם, רד"ק].
From a military standpoint, this invasion took place after Hazael had already dealt a crushing blow to the northern Kingdom of Israel [ביאור שטיינזלץ]. He then attacked and captured the city of Gath. Although originally a Philistine city, Gath was under the control of the kings of Judah at the time, having been conquered by King David generations earlier [מלבי"ם, רד"ק, אברבנאל]. After securing Gath, Hazael set his sights on Jerusalem, intending to wage war against the capital [ביאור שטיינזלץ].
This sequence of events presents a historical question. The Book of Chronicles describes a brutal war where the Aramean army actually invaded Jerusalem, slaughtered its officials, and looted the city. However, the events described here suggest that Hazael only planned to attack but did not follow through. To resolve this, the primary approach among commentators is that there were two entirely separate military campaigns [רלב"ג, רד"ק, אברבנאל].
The first campaign involved Hazael personally marching toward Jerusalem. He never actually entered the city because King Joash, driven by fear, bribed him with the treasures of the Temple, successfully convincing the Aramean king to retreat. The devastating war described in Chronicles took place about a year later. This second attack was triggered by another terrible sin committed by Joash, who murdered the prophet Zechariah in the courtyard of the House of God. During this second campaign, Hazael himself did not lead the charge; rather, his army attacked. They struck Joash, leaving him wounded and sick in his bed, which ultimately led to his own servants conspiring against him and putting him to death.