Genesis 20:3

20:3 But God appeared to Abimelech in a dream at night and said to him, “You are as good as dead because of the woman you have taken, for she is someone else’s wife.”

Genesis 21:22-32

21:22 At that time Abimelech and Phicol, the commander of his army, said to Abraham, “God is with you in all that you do. 21:23 Now swear to me right here in God’s name that you will not deceive me, my children, or my descendants. Show me, and the land where you are staying, the same loyalty that I have shown you.”

21:24 Abraham said, “I swear to do this.” 21:25 But Abraham lodged a complaint against Abimelech concerning a well that Abimelech’s servants had seized. 21:26 “I do not know who has done this thing,” Abimelech replied. “Moreover, you did not tell me. I did not hear about it until today.”

21:27 Abraham took some sheep and cattle and gave them to Abimelech. The two of them made a treaty. 21:28 Then Abraham set seven ewe lambs apart from the flock by themselves. 21:29 Abimelech asked Abraham, “What is the meaning of these seven ewe lambs that you have set apart?” 21:30 He replied, “You must take these seven ewe lambs from my hand as legal proof that I dug this well.” 21:31 That is why he named that place Beer Sheba, because the two of them swore an oath there.

21:32 So they made a treaty at Beer Sheba. Then Abimelech and Phicol, the commander of his army, returned to the land of the Philistines.