2 Chronicles 12:5
Then came Shemaiah the prophet to Rehoboam, and to the princes of Judah, that were gathered together to Jerusalem because of Shishak, and said unto them, Thus saith the LORD, Ye have forsaken me, and therefore have I also left you in the hand of Shishak.
When Shemaiah the prophet came to Rehoboam and the princes of Judah gathered together at Jerusalem because of Shishak, he delivered the word of the Lord that because they had forsaken Him, He had left them in the hand of Shishak. The abandonment of God by the king, the leaders, and the people was met by God withdrawing His protection and leaving them in their enemy's power. Shishak's invasion, with its defeat and losses for Judah, was therefore the direct consequence and judgment for their unfaithfulness and transgression in forsaking God.
The losses they suffered brought Rehoboam and the leaders to humble themselves and to acknowledge that the Lord is righteous. Because they humbled themselves, Jerusalem was spared from utter destruction. Yet they were left subject to Shishak, that they might learn by experience the difference between serving God and serving the kingdoms of earth.