"God leads astray whom He wills and guides whom He wills."
God has two kinds of Will. One is His (pre-eternal) Decree concerning the creation, including responsible, conscious beings. This Will, called Mashiah, is absolute with regard to things and unconscious beings, while it takes into consideration the (future) will of responsible, conscious beings. That is, God knows beforehand in what way those beings will use their free will and decrees accordingly. God's other Will (iradah) entails what He demands from His servants and denotes those things with which He is pleased.
In this verse God leads astray whom He wills means that He lets go astray those who choose to follow Satan and the promptings of their carnal soul, with the result that they follow their fancies and personal ideas and commit evil deeds that, though not based on true knowledge, seem just to them. As for, He guides whom He wills, this denotes those who choose to resist the temptations of Satan and their carnal soul, and instead follow the guidance that God sends through His Messengers, and they see as good whatever God decrees as so.
"The Quran: Annotated Interpretation in Modern English" - Ali Unal, p. 896