Balaam devised a plan to curse the Israelites after failing to do so. His plan was to entice them to engage in idolatrous worship of Baal and Ashtaroth, which would cause God to become their enemy and allow them to be conquered. Many Israelites were seduced by Moabite women into sin, leading to a plague. When an Israelite leader openly sinned with a Midianite princess, Phinehas killed them, ending the plague. God then commanded the Israelites to wage war on the Midianites for tempting His people into apostasy.