Deuteronomy 23:5

5But the Lord your God would not listen to Balaam; instead the Lord your God turned athe curse into a blessing for you, because the Lord your God loved you.
Copyright information for ESV