David is told that the Philistines are attacking Keilah and robbing the threshing floors. He inquires of the Lord whether to go and fight them, and the Lord says yes. His men are afraid, because they are already in danger in Judah. David inquires again, and the Lord assures him. David goes with his men, defeats the Philistines and saves the inhabitants of Keilah. Abiathar had come to David with the ephod.
Saul learns that David is at Keilah and thinks God has given him into his hand, because he has shut himself in a city with gates and bars. He summons the people to besiege it. David knows this and asks Abiathar to bring the ephod. He inquires of the Lord whether Saul will come down and whether the men of Keilah will surrender him. The Lord says yes to both. David leaves with about six hundred men and Saul gives up going to Keilah.
David stays in the strongholds of the wilderness of Ziph, and Saul seeks him every day, but God does not give him into his hand. Jonathan goes to him at Horesh and strengthens his trust in God: he tells him not to fear, that Saul will not find him, that David will be king over Israel and that he himself will be second. They make a covenant before the Lord.
The Ziphites go up to Saul and reveal where David is hiding. Saul blesses them and asks them to make sure of his whereabouts. Saul pursues David in the wilderness of Maon. He is on one side of the mountain and David on the other, and as Saul and his men are about to surround him, a messenger comes saying the Philistines have raided the land. Saul withdraws, and that place is called the Rock of Escape. David goes up to the strongholds of Engedi.