Turning back the pages of the Bible one discovers that God has been watching Canaan for some time. Back during Abraham's time God said that the iniquity of the Amorites was not yet full. (Genesis 15:16) But it did become full. They burned their children to honor their god, Molech (Leviticus 18:21), practiced sodomy and bestiality (Leviticus 18:23,24), and defiled God's sanctuary and holy name (Leviticus 20:3). They were so despicable that not only was God set against them but the land and people themselves were set against those who practiced such things. (Leviticus 18:27-30) These people needed to be cut off--much like a doctor who removes a leg with gangrene to save the patient.
Joshua had tried to whip Ai once before but he didn't get the job done. It was because Israel had sin in their own camp. When they conquered Jericho, all of the spoils of war were supposed to be destroyed. But, of course, there's always one who sees something he just has to have. Once he was discovered and the sin was destroyed, then Joshua devised another plan.
This time (Joshua 8) part of the army lay in wait behind the town while the rest of the army approached Ai. When the king saw them coming, his army marched out of the city and attacked the coming Israelites who turned tail and ran. As soon as the Amorites (the people of Ai) were in the open the rest of the army attacked them from behind. God was with them and victory belonged to the Israelites.
This isn't the end of the story. There's more. The citizens of Gibeon, a nearby town, had heard that all the land was to belong to the Israelites and the inhabitants were to be destroyed. They posed as poor distant wayfarers and talked Joshua and the leaders into giving them a treaty that they wouldn't be attacked. Joshua and the leaders gave their oath.
Gibeon was an important city to the Amorites. The kings of five other Amorite cities banded together to attack Gibeon. When they, the Gibeonites, heard what was going to happen, Gibeon called on Joshua to help them. Joshua did because of the treaty and it's clear how the rest of the story goes--the kings were conquered, and the cities to the south were conquered. It's all in Joshua 10. Also, the day the sun and moon stood still are recorded in this chapter.
Preacher, do you think things like that still happen today? Does iniquity still abound today as it did in the days of old? Does God still fight for his people? "And except those days should be shortened, there should be no flesh saved: but for the elect's sake those days shall be shortened." (Matthew 24:22) "Behold he that keepeth Israel shall neither slumber nor sleep...The Lord shall preserve thy going out and thy coming in from this time forth, and even for evermore.(Psalm 121:4,8)