The Amalekites attacked the Israelites while they were in Rephidim. They were defeated by Joshua. God then said, he would destroy the people of the Amalekites.
The explorers sent out by Moses into the land of Canaan, discovered, that they lived in the Negev, in the valleys, in the land of Canaan. After some rioting against God by the Israelites camp, they decided to attack the Amalekites and Canaanites even though God was not for them. As a result, the Amalekites and Canaanites defeated the attacking Israelites.
The prophet Balaam prophesied, that the Amalekites would come to ruin, even though it had been the first of the nations.