“It certainly seems as though divine foreknowledge is incompatible with there being human free choice. For what God foreknows shall necessarily come to be in the future, while the things brought about by free choice do not issue from any necessity. And, if divine foreknowledge and human free choice cannot both exist, it is impossible for God’s foreknowledge, which foresees all things, to coexist with something happening through free choice.
Yet if it can be shown that the ‘impossibility’ here is apparent rather than real, the seeming opposition between God’s knowledge and human freedom would be shown to be unreal.
So let us affirm the coexistence both of divine foreknowledge (which seems to require the necessary existence of future things) and of free choice (by which many things are believed to occur apart from any necessity), and let us see whether it is impossible for these to be coexistent. If they cannot, there arises as a consequence a second ‘impossibility’. For that which entails an impossibility is itself impossible. But if something is going to occur freely, God, who foreknows all that shall be, foreknows this very fact. And whatever God foreknows shall necessarily happen in the way in which it is foreknown.
So it is necessary that it shall happen freely, and there is therefore no conflict whatsoever between a foreknowledge which entails a necessary occurrence and a free exercise of an uncoerced will. For it is both necessary that God foreknows what shall come to be and that God foreknows that something shall freely come to be.
You may say to me: ‘You are still not removing from me the necessity of sinning or not sinning since God foreknows that I am going to sin or not sin, and it is therefore necessary that I sin, if I sin, or that I not sin if I do not sin.’
From this it follows that I am free to sin or not to sin because God knows that what shall come to pass shall be free. Do you see, then, that it is not impossible for God’s foreknowledge (through which he foreknows the future events which are said to happen necessarily) to coexist with freedom of choice (by which much is done freely)? For if this is impossible, the consequence is something impossible.’”
But then I, in turn, respond: ‘You should not say: “God only foreknows that I am going to sin or not.” You should say: “God foreknows that I am going freely to sin or not,”
-Anselm of Canterbury, De Concordia: The Compatibly of God’s Foreknowledge, Predestination, and Grace with Human Freedom, 1.