What is the meaning of "va'Yachalosh Yehoshua ... "?
Rashi: It means that Yehoshua severed the heads of Amalek's strong men, keeping alive only the weak ones. He did not kill them all, due to a Divine command. 1
Rashbam: It means that he completely vanquished Amalek. 2
Gur Aryeh: The proof is, that if Yehoshua was powerful enough to behead their mighty warriors, certainly he should have been able to kill their weaker ones! Seeing as Yehoshua did not do so, it must be because that is what Hashem had commanded. (As for why Hashem did so, see the following question.)
Rashbam: As in Shemos 32:18 .
QUESTIONS ON RASHI
Rashi writes: "Yehoshua weakened [Amalek] - He left only the weak among them; he did not kill all of them.... He acted in accordance with the Word of the Shechinah." Why didn't Hashem allow Yehoshua to wipe out Amalek completely?
Maharal (Gevuros Hashem, end Ch. 42, p. 161): Bnei Yisrael had not yet reached the great level at which Hashem's Name would be whole (see Rashi to 17:16).
Lev Eliyahu (p. 97): Hashem makes a nation fall only after its angel has fallen, and the angel of Esav will not fall as long as the Yetzer ha'Ra is among us.