Romans 8:29-30 lays out what theologians call the "golden chain of redemption." God foreknew those who would be His, predestinated them to be conformed to Christ's image, called them, justified them, and glorified them. Notice that foreknowledge comes before predestination — God's predestination is based on His perfect foreknowledge.
This does not mean God arbitrarily chose some for salvation and others for damnation without regard to their response to the gospel. Rather, God, who exists outside of time and sees the end from the beginning (Isaiah 46:10), knew before the foundation of the world who would respond to His call in faith.