Summary: The Philistine officers told Achish, the king of Gat that David should not be trusted. David reluctantly left the battle front. He found the city of Ziklag had been attacked and burnt by Amalek, David’s two wives together with the women and children had been captured. God reassured David that he would overcome the Amalekites. David’s army attacked them and rescued all the captives and possessions.
A deeper look: David had exiled himself to the land of the Philistines and found sanctuary with the Philistine king of Gat, Achish. In turn, David and his army would offer protection to the Philistine generals. David’s time in Gat had protected him from Shaul’s attempts on his life. Yet the Philistine generals now questioned David’s allegiance given that until now he had been their sworn enemy (Samuel I 29:5).
David and his men returned to Ziklag which Achish had given them to settle (ibid. 27:6). Yet when they arrived, they discovered that the army of Amalek had attacked the city and captured the women and children. Since David and his men had been with Achish, they had been forced to leave the city unprotected.
The people were ready to stone David (ibid. 30:6) because the men blamed David for allowing their families to be exposed to such danger (Metzudot David loc. cit.). While many would have crumbled under the pressure of losing both of his own wives and bearing the responsibility for the tragic losses his men suffered, Rabbi David Kimchi (d. 1235) notes that David drew his strength from his unshakable belief in God (Radak loc. cit.).
With the help of the Urim v’Tumim, God led David and his men to the Amalekite attackers where they routed them, rescued their captives and recovered their belongings. Yet ‘four hundred youths who were riding camels’ managed to escape (Samuel I 30:17). Rabbi Meïr Leibush ben Yehiel Michel Wisser (d. 1879) explains that they were able to escape because they were young and agile, and camels can run very fast (Malbim loc. cit.).
Rashi (d. 1105) however, offers a deeper connection. When Esau, the grandfather of Amalek (Genesis 36:12) went to meet with Jacob, he mobilised an army of four hundred men (Genesis 32:7). Yet when Jacob and Esau parted peacefully, these four hundred men deserted Esau one by one. In their merit, God now spared four hundred Amalekites. Yet the victory was brief, as an even greater trouble was brewing.