Anselm on God’s Foreknowledge and the Freedom of Human Sin

“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.’ 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 if I am going to freely sin or not.” 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.'”

-Anselm, De Concordia §1. This is the opening of his argument for the compatibility of human choice and God’s foreknowledge.