Numbers 23&24
Balak was the king of moab , he consulted with Ballam a prophet to curse the isratelites who were seen as a threat to the moabites. The israelites were the newest settlers and the moabites saw them as a serious threat.
The same story continues to chapter 24, Balaam was not able to pronounce a curse on the Israelites instead kept blessing them .
Chapter 25
This period of time, there was inter-marriage and sexual relationship between the moabites and the israelites. Meanwhile in the process many israelites began to worship the god of the moabites 'baalpeor' .
However God became angry with the Israelites and a pestilence broke out in their settlements .