But he was rebuked for his transgression. "A dumb donkey, speaking with a human voice, restrained the madness of the prophet" (2 Pet. 2:16). From this we learn that Balaam, having once received a prohibition from God against going to Balak, was again driven to it by his arrogant passion, which he nourished with his frenzied sorcery, but, bridled by the fear of God and the terrible signs that occurred during the journey, he did not change the word of blessing, which was a matter not of sorcery. For the prophets utter their oracles with awareness. For this reason the apostle also called him a "p...rophet," as one who was aware of what he was saying. For if he had not been aware of his words, he could not have chosen what was better. Thus, his blessing was a matter not of divination, but of the power of God.
Source: Commentary on 2 Peter