Hashem hardens the hearts of the wicked - in order to destroy them
For it was from Hashem to harden their hearts, (that they should come) against Israel in battle, that they might destroy them completely, and that they might have no favor, that they might destroy them as Hashem had commanded Moshe. (Yehoshua 11:20)