The Lord had told Israel to go around Edom since this was territory he had given to Esau. The text of Deuteronomy 2:22 says that the Lord used the descendants of Edom to drive out the Horites from their land, which is what the Lord is going to do when he uses the descendants of Jacob to drive out the Canaanites from the Promised Land.
. . . . . . . click image for a larger map . . . . . . . .
Moses led Israel up the Kings' Highway on the east side of Edom and stopped at the Zered Valley at the base of the Dead Sea. This is where the Moabites saw Israel approaching and their King Balak sent for Balaam. Israel was going to pass by Moab peacefully also since they were descendants of Lot. But, when Israel was enticed to sin with the Moabite woman and join in the worship of the Baal of Peor, the Lord commanded Moses to treat the Moabites as enemies in Numbers 25:16-18:
"The Lord said to Moses, 'Treat the Midianites as enemies and kill them. They treated you as enemies when they deceived you in the Peor incident involving their sister Kozbi, the daughter of a Midianite leader, the woman who was killed when the plague came as a result of that incident.' ” - Numbers 25:16-18
Previously, when the Lord had given the land of Moab to the Moabites, they had to drive out the Emites (which were also called Rephaites) according to Deuteronomy 2:10-11. The word Rephaites means "shades" and "ghosts," but the Ammonites preferred to call them Emim which means "frightful ones."
In Deuteronomy 2:13 the Lord told Moses to cross the Zered Valley and Israel approached the land of Ammon as they continued up the Kings' Highway to the Arnon River, or the Arnon Gourge. On the other side of the Arnon Gourge lay the territory of the Amorites and their King Sihon between the Jordan River and the land of the Ammonites. In Deuteronomy 2:19 Moses is told not to harass the Ammonites because they are the descendents of Lot and had also been given their land by the Lord. The Ammonites had also had to drive out the Rephaittes ("shades," "ghosts"), but they called them Zamzummites. The name Zammabu is a personal name found in a Babylonian list of kings. The Greek Septuagint translates "Zamzummites" as "mighty ones."
But, the Lord tells Moses that when Israel enters the land of the Amorites (which is between Ammon and the Jordan River) and their King Sihon, they are to "engage him in battle."
“Set out now and cross the Arnon Gorge. See, I have given into your hand Sihon the Amorite, king of Heshbon, and his country. Begin to take possession of it and engage him in battle. This very day I will begin to put the terror and fear of you on all the nations under heaven. They will hear reports of you and will tremble and be in anguish because of you.” - Deuteronomy 2:24-25
One additional note, the land of Philistia was at one time occupied by the Avvites, but were driven out by a people coming from Caphtor, which is the Greek island of Crete. This was the early stages of the arrival of the people who would become the Philistines. It is worth mentioning that several of the cultural practices of the Philistines reflect an ancient Greek culture.