Zechariah 9:5

Ashkelon shall see it, and fear; Gaza also shall see it, and be very sorrowful, and Ekron; for her expectation shall be ashamed; and the king shall perish from Gaza, and Ashkelon shall not be inhabited.

Zechariah 9:5 belongs to the latter part of Zechariah, chapters 9 to 14, which has a much wider sweep than the first part of the book and looks forward to final restoration, being rich in predictions of the Messianic King and kingdom, Christ's kingdom, the great day of the Lord, and the judgment and punishment of the wicked and of those who reject God. As part of that prophecy of restoration, it was given to encourage Zerubbabel and Ezra in building the temple and restoring Jerusalem, and that restoration reformation movement is a type of the last reformation.

The verse predicts the conquest of Ashkelon, Gaza, and Ekron by Alexander the Great as part of his conquest of the principal cities in the vicinity of Jerusalem. Those Philistine cities lay on his route to Egypt and each was captured and devastated as he advanced, bringing fear and suffering. The fear and sorrow came from learning of the defeat of Tyre, with disappointed hope that Tyre would resist Alexander, which is what is meant by her expectation being ashamed. The perishing of the king from Gaza was fulfilled in its Persian governor Betis, who resisted strongly but was cruelly killed by Alexander after the siege. The statement that Ashkelon shall not be inhabited was fulfilled in Ashkelon being left uninhabited in that conquest. The destruction of these cities contrasts with the remarkable preservation and deliverance of Jerusalem itself, even when Alexander had determined to destroy it.

In connection with the chapter's prophecy of Zion's king, nothing in Zechariah 9 indicated that the kingdom would not be set up when the royal proclamation was given, so the disciples fulfilled the prophecy but misunderstood the event. Only after their disappointment did they learn that Christ had to suffer before coming in his kingdom.