God told Abraham that he was going to judge Sodom for its sins. Lot, Abraham’s nephew, lived in Sodom and this fact prompted Abraham to intercede for the city.
Then Abraham drew near and said, “Will you indeed sweep away the righteous with the wicked? Suppose there are fifty righteous within the city. Will you then sweep away the place and not spare it for the fifty righteous who are in it? Far be it from you to do such a thing, to put the righteous to death with the wicked, so that the righteous fare as the wicked! Far be that from you! Shall not the Judge of all the earth do what is just?”
And the Lord said, “If I find at Sodom fifty righteous in the city, I will spare the whole place for their sake.”
. . . . .
Then he said, “Oh let not the Lord be angry, and I will speak again but this once. Suppose ten are found there.”
He answered, “For the sake of ten I will not destroy it.” (Genesis 18:23-26,32)
Abraham’s nephew Lot separated himself from Abraham and went to live in Sodom. His decision soon got him in trouble. Genesis 14:1-16 describes how a coalition of kings led by Chedorlaomer overcame Sodom and its allies and took as prisoners the people of those cities, including Lot. When Abraham heard of this he called out his followers and rescued Lot and the other captives.
After his return from the defeat of Chedorlaomer and the kings who were with him, the king of Sodom went out to meet him at the Valley of Shaveh (that is, the King’s Valley). (Genesis 14:17)
But before the king of Sodom met him he encountered Melchizedek.
And Melchizedek king of Salem brought out bread and wine. (He was priest of God Most High.) And he blessed him and said,
“Blessed be Abram by God Most High,
Possessor of heaven and earth;
and blessed be God Most High,
who has delivered your enemies into your hand!”
And Abram gave him a tenth of everything. (Genesis 14:18-20)