Balaam kept seeking the Lord, hoping that He would change His mind and curse Israel for the King of Moab, who had hired Balaam to curse Israel. However, the prophet eventually came to the realization that the Lord would not change, and had determined to bless Israel. The Bible says,
Now when Balaam saw that it pleased the Lord to bless Israel, he did not go as at other times, to seek to use sorcery, but he set his face toward the wilderness. And Balaam raised his eyes, and saw Israel encamped according to their tribes; and the Spirit of God came upon him (Numbers 24.1–2).
Balaam did just as he promised the king of Moab that he would do, speak the word of the Lord. Then when Balaam would not go to the Lord anymore, the prophet looked upon Israel and by the Spirit of God blessed Israel.
However, later Balaam showed the king of Moab how he could get the Lord to curse Israel. Too bad, because the prophet had spoken the truth, although he was greedy, and he could have been a righteous man.