A bunch of kings in the area start getting nervous about Joshua’s inept bungling into conquest, and start talking about forming an alliance. Then that narrative is suddenly dropped (to be resumed in the next chapter) in favour of the one involving the Gibeonites (who will also make a reappearance in the next chapter).
The Gibeonites, you see, have figured out that Joshua has the ark – think of it like the nuclear arsenal of the ancient world. So long as Joshua has God on his side, they can’t hope to fight him and survive – the only option is to join him. But there’s a problem, Deut. 20:15-16 forbids the Israelites from becoming friendly with anyone currently living in the Promised Land. So the Gibeonites, probably reflecting for about half a moment on Joshua’s decision-making skills so far, decide that a little trickery is worth a try.
They then go to Joshua and introduce themselves as emissaries from a distant land, showing him their worn gear as proof of their long journey (though Gibeon itself is a mere seven miles away from Ai, according to my study Bible, p.273). Joshua, choosing not to consider that he hasn’t been in the area long enough for emissaries to have been sent from much further than the real Gibeon and apparently unwilling to check in with God or, heaven’s forbid, check a map, strikes an alliance with the Gibeonites.
It takes him three whole days to finally come back with a “heeeey, wait a minute!” But when he does, it’s too late. The alliance has been struck and he can’t back out of it now.
Joshua, displaying once again that he is not the leader of the Israelites because of any personal intelligence that recommends him above his fellows, confronts the Gibeonites and asks them “Why did you deceive us?” (Josh. 9:22). Like, really? He needed to ask after just burning Jericho and Ai to the ground, slaughtering every living thing (except the trees)?
Realizing that he can’t slaughter the Gibeonites, Joshua does the next best thing: he enslaves them. Henceforth, they shall be responsible for the hewing of wood and the drawing of water for the as-yet-non-existent Temple.
EDIT: According to Paul Davidson of Is That In The Bible?, it appears that Gibeon was not inhabited during the late Bronze Age.