Even as Saul returned from pursuing the Philistines, he was informed that David was in the En-gedi wilderness.
References for 1 Samuel 24:1
So Saul took three thousand men selected from all Israel and went to look for David and his soldiers near the rocks of the wild goats.
He came to the sheep pens beside the road where there was a cave. Saul went into the cave to use the restroom. Meanwhile, David and his soldiers were sitting in the very back of the cave.
References for 1 Samuel 24:3
David's soldiers said to him, "This is the day the LORD spoke of when he promised you, ‘I will hand your enemy over to you, and you can do to him whatever you think best.'" So David snuck up and cut off a corner of Saul's robe.
But immediately David felt horrible that he had cut off a corner of Saul's robe.
References for 1 Samuel 24:5
"The LORD forbid," he told his men, "that I should do something like that to my master, the LORD's anointed, or lift my hand against him, because he's the LORD's anointed!"
So David held his soldiers in check by what he said, and he wouldn't allow them to attack Saul. Saul then left the cave and went on his way.
References for 1 Samuel 24:7
Then David also went out of the cave and yelled after Saul, "My master the king!" Saul looked back, and David bowed low out of respect, nose to the ground.
David said to Saul, "Why do you listen when people say, ‘David wants to ruin you'?
Look! Today your own eyes have seen that the LORD handed you over to me in the cave. But I refused to kill you. I spared you, saying, ‘I won't lift a hand against my master because he is the LORD's anointed.'
References for 1 Samuel 24:10
Look here, my protector! See the corner of your robe in my hand? I cut off the corner of your robe but didn't kill you. So know now that I am not guilty of wrongdoing or rebellion. I haven't wronged you, but you are hunting me down, trying to kill me.
May the LORD judge between me and you! May the LORD take vengeance on you for me, but I won't lift a hand against you.
As the old proverb goes, ‘Evil deeds come from evildoers!' but I won't lift a hand against you.
So who is Israel's king coming after? Who are you chasing? A dead dog? A single flea?
May the LORD be the judge and decide between you and me. May he see what has happened, argue my case, and vindicate me against you!"
As soon as David finished saying all this to Saul, Saul said, "David, my son, is that your voice?" Then he broke down in tears,
telling David, "You are more righteous than I am because you have treated me generously, but I have treated you terribly.
Today you've told me the good you have done for me—how the LORD handed me over to you, but how you didn't kill me.
When someone finds an enemy, do they send the enemy away in peace? May the LORD repay you with good for what you have done for me today.
Now even I know that you will definitely become king, and Israel's kingdom will flourish in your hands.
Because of that, make a solemn pledge to me by the LORD that you won't kill off my descendants after I'm gone and that you won't destroy my name from my family lineage."
David made a solemn pledge to Saul. Then Saul went back home, but David and his soldiers went up to the fortress.