1 SamuelChapter 29

The Philistines gathered all their forces at Aphek, while Israel camped by the spring in Jezreel.
As the Philistine rulers marched past with their units of hundreds and thousands, David and his men came at the rear with Achish.
The Philistine commanders asked, "What are these Hebrews doing here?" Achish answered them, "This is David, the servant of Saul king of Israel. He has been with me now for days, even years, and from the day he deserted to me until now I have found no fault in him.
But the Philistine commanders were angry with him and said, "Send the man back. Let him return to the place you assigned him. He must not go into battle with us, or he will turn against us in the fighting. How better could he win back his master's favor than with the heads of these men of ours?"
Isn't this the David they sang about in their dances: 'Saul has slain his thousands, and David his tens of thousands'?"
So Achish called David and said to him, "As surely as the LORD lives, you have been honest, and it would please me to have you march out and back with me in the army, for I have found no wrong in you from the day you came to me until now. But the rulers do not approve of you.
Now go back, and go in peace; do nothing to displease the Philistine rulers."
"But what have I done?" David asked. "What have you found against your servant from the day I came to you until now, that I should not go and fight against the enemies of my lord the king?"
Achish answered, "I know you are as pleasing to me as an angel of God. But the Philistine commanders have said, 'He must not go up with us into battle.'
So get up early in the morning, you and your master's servants who came with you; set out at daybreak, as soon as it is light, and go."
So David and his men got up early in the morning to return to the land of the Philistines, and the Philistines went up to Jezreel.