22 And it came to pass at that time that Abimelech and Phichol, the commander of his army, spoke to Abraham, saying, “God is with you in all that you do.
23 Now therefore, swear to me by God that you will not deal falsely with me, with my offspring, or with my posterity; but that according to the kindness that I have done to you, you will do to me and to the land in which you have dwelt.”
24 And Abraham said, “I will swear.”
25 Then Abraham rebuked Abimelech because of a well of water which Abimelech’s servants had seized.
26 And Abimelech said, “I do not know who has done this thing; you did not tell me, nor had I heard of it until today.”
27 So Abraham took sheep and oxen and gave them to Abimelech, and the two of them made a covenant.
28 And Abraham set seven ewe lambs of the flock by themselves.
29 Then Abimelech asked Abraham, “What is the meaning of these seven ewe lambs which you have set by themselves?”
30 And he said, “You will take these seven ewe lambs from my hand, that they may be my witness that I have dug this well.”
31 Therefore he called that place Beersheba, because the two of them swore an oath there.
32 Thus they made a covenant at Beersheba. So Abimelech rose with Phichol, the commander of his army, and they returned to the land of the Philistines.
33 Then Abraham planted a tamarisk tree in Beersheba, and there called on the name of the Lord, the Everlasting God.
34 And Abraham stayed in the land of the Philistines many days.
Everlasting God (Hebrew El Olam) [v.33]. The Hebrew Olam is used in Scripture: (a) of secret or hidden things (e.g. Leviticus 5:2, “hidden”; 2 Kings 4:27, “hid”; Psalm 10:1, “hide”); (b) of an indefinite time or age (Leviticus 25:32, “at any time”, Joshua 24:2, “in old time”). Hence the word is used to express the eternal duration of the Being of God (Psalm 90:2, “from everlasting to everlasting”); it is also the Hebrew synonym of the Greek aion, age. — Scofield, page 32.
Abraham was quite willing to make a treaty [with Abimelech, the king of the Philistines]. However, on bone of contention had developed, and Abraham used this occasion as the means to get that problem cleared up. Abraham had dug a well at Beersheba and, although Beersheba was not in the country of Abimelech, some of Abimelech’s servants had raided the area and had captured the well from Abraham’s servants. The foray had not been known to Abimelech and he quickly agreed to return the well to Abraham. In return, Abraham gave sheep and oxen to Abimelech, thus giving him back at least a portion of the gift Abimelech had pressed on him earlier (Genesis 20:14). Also, Abraham selected seven ewe lambs, and indicated to Abimelech that these (the number seven representing completeness, sealing the covenant, and symbolizing Abraham’s permanent right to the well) were to be a special witness. Bot men agreed fully to the treaty, and the place was therefore named Beersheba, which means both “well of the oath” and well of the seven.” … Abraham would eventually come back to Beersheba to dwell (Genesis 22:19); but for the present he went back to the place where he had been living in the land of the Philistines, where he continued to live for many years, until, in fact, Isaac was a grown man. — Morris, page 372.
God here prompts Abimelech, along with Phicol the commander of his army, to make an oath of peace with Abraham on behalf of their people (i.e., the Philistines; cf. Genesis 26:1). This is especially significant when one considers that Abraham himself perversely misrepresented how a believer in the true God should behave toward others, having gravely offended and sinned against Abimelech in the previous chapter. Yet, contrary to human expectation, Abimelech is drawn—not to Abraham, but to the God of Abraham, whom he affirms is with Abraham in all that he does. — Wechsler, page 208.