22:1 Then the people of Israel set out and camped in the plains of Moab beyond the Jordan at Jericho. 2 And Balak the son of Zippor saw all that Israel had done to the Amorites. 3 And Moab was in great dread of the people, because they were many. Moab was overcome with fear of the people of Israel. 4 And Moab said to the elders of Midian, “This horde will now lick up all that is around us, as the ox licks up the grass of the field.” So Balak the son of Zippor, who was king of Moab at that time, 5 sent messengers to Balaam the son of Beor at Pethor, which is near the River in the land of the people of Amaw,  to call him, saying, “Behold, a people has come out of Egypt. They cover the face of the earth, and they are dwelling opposite me. 6 Come now, curse this people for me, since they are too mighty for me. Perhaps I shall be able to defeat them and drive them from the land, for I know that he whom you bless is blessed, and he whom you curse is cursed.”
7 So the elders of Moab and the elders of Midian departed with the fees for divination in their hand. And they came to Balaam and gave him Balak's message. 8 And he said to them, “Lodge here tonight, and I will bring back word to you, as the Lord speaks to me.” So the princes of Moab stayed with Balaam. 9 And God came to Balaam and said, “Who are these men with you?” 10 And Balaam said to God, “Balak the son of Zippor, king of Moab, has sent to me, saying, 11 ‘Behold, a people has come out of Egypt, and it covers the face of the earth. Now come, curse them for me. Perhaps I shall be able to fight against them and drive them out.’” 12 God said to Balaam, “You shall not go with them. You shall not curse the people, for they are blessed.” 13 So Balaam rose in the morning and said to the princes of Balak, “Go to your own land, for the Lord has refused to let me go with you.” 14 So the princes of Moab rose and went to Balak and said, “Balaam refuses to come with us.”
15 Once again Balak sent princes, more in number and more honorable than these. 16 And they came to Balaam and said to him, “Thus says Balak the son of Zippor: ‘Let nothing hinder you from coming to me, 17 for I will surely do you great honor, and whatever you say to me I will do. Come, curse this people for me.’” 18 But Balaam answered and said to the servants of Balak, “Though Balak were to give me his house full of silver and gold, I could not go beyond the command of the Lord my God to do less or more. 19 So you, too, please stay here tonight, that I may know what more the Lord will say to me.” 20 And God came to Balaam at night and said to him, “If the men have come to call you, rise, go with them; but only do what I tell you.” 21 So Balaam rose in the morning and saddled his donkey and went with the princes of Moab.
22 But God's anger was kindled because he went, and the angel of the Lord took his stand in the way as his adversary. Now he was riding on the donkey, and his two servants were with him. 23 And the donkey saw the angel of the Lord standing in the road, with a drawn sword in his hand. And the donkey turned aside out of the road and went into the field. And Balaam struck the donkey, to turn her into the road. 24 Then the angel of the Lord stood in a narrow path between the vineyards, with a wall on either side. 25 And when the donkey saw the angel of the Lord, she pushed against the wall and pressed Balaam's foot against the wall. So he struck her again. 26 Then the angel of the Lord went ahead and stood in a narrow place, where there was no way to turn either to the right or to the left. 27 When the donkey saw the angel of the Lord, she lay down under Balaam. And Balaam's anger was kindled, and he struck the donkey with his staff. 28 Then the Lord opened the mouth of the donkey, and she said to Balaam, “What have I done to you, that you have struck me these three times?” 29 And Balaam said to the donkey, “Because you have made a fool of me. I wish I had a sword in my hand, for then I would kill you.” 30 And the donkey said to Balaam, “Am I not your donkey, on which you have ridden all your life long to this day? Is it my habit to treat you this way?” And he said, “No.”
31 Then the Lord opened the eyes of Balaam, and he saw the angel of the Lord standing in the way, with his drawn sword in his hand. And he bowed down and fell on his face. 32 And the angel of the Lord said to him, “Why have you struck your donkey these three times? Behold, I have come out to oppose you because your way is perverse  before me. 33 The donkey saw me and turned aside before me these three times. If she had not turned aside from me, surely just now I would have killed you and let her live.” 34 Then Balaam said to the angel of the Lord, “I have sinned, for I did not know that you stood in the road against me. Now therefore, if it is evil in your sight, I will turn back.” 35 And the angel of the Lord said to Balaam, “Go with the men, but speak only the word that I tell you.” So Balaam went on with the princes of Balak.
36 When Balak heard that Balaam had come, he went out to meet him at the city of Moab, on the border formed by the Arnon, at the extremity of the border. 37 And Balak said to Balaam, “Did I not send to you to call you? Why did you not come to me? Am I not able to honor you?” 38 Balaam said to Balak, “Behold, I have come to you! Have I now any power of my own to speak anything? The word that God puts in my mouth, that must I speak.” 39 Then Balaam went with Balak, and they came to Kiriath-huzoth. 40 And Balak sacrificed oxen and sheep, and sent for Balaam and for the princes who were with him.
41 And in the morning Balak took Balaam and brought him up to Bamoth-baal, and from there he saw a fraction of the people. (ESV)