Balaam was hired to curse the Israelites.
An Ammonite or Moabite shall not enter into the congregation of the LORD; even to their tenth generation shall they not enter into the congregation of the LORD for ever ... because they hired against thee Balaam the son of Beor of Pethor of Mesopotamia, to curse thee. Deuteronomy 23:3-4
Balaam cursed the Israelites, but God turned his curse into a blessing.
Then Balak the son of Zippor, king of Moab, arose and warred against Israel, and sent and called Balaam the son of Beor to curse you: But I would not hearken unto Balaam; therefore he blessed you still: so I delivered you out of his hand. Joshua 24:9-10
The Ammonite and the Moabite should not come into the congregation of God for ever; Because they met not the children of Israel with bread and with water, but hired Balaam against them, that he should curse them: howbeit our God turned the curse into a blessing. Nehemiah 13:1-2
Balaam refused the curse the Israelites
Balak the king of Moab hath brought me from Aram, out of the mountains of the east, saying, Come, curse me Jacob, and come, defy Israel. How shall I curse, whom God hath not cursed? or how shall I defy, whom the LORD hath not defied? Numbers 23:7-8
Balak's anger was kindled against Balaam, and he smote his hands together: and Balak said unto Balaam, I called thee to curse mine enemies, and, behold, thou hast altogether blessed them these three times. Numbers 24:10