Summary: After the victories of Jericho and Ai, the kings of the remaining Canaanite nations gathered to wage war against Joshua and the Jewish people. The people of Gibeon however devised a cunning strategy to trick the Jewish people into making a covenant with them.
In depth: God commands that a Jewish army must offer an enemy the opportunity to flee or try to make peace with them before attacking (Deuteronomy 20:10). Maimonides (d. 1204) elucidates the conditions for peace which include the enemy accepting the seven Noachide laws (Talmud Sanhedrin 56a). Refusal of either alternative would result in war. The Girgashites were the only Canaanite nation who chose to flee (see Rashi on Exodus 34:11).
The Gibeonites who lived in the city of Givon were members of the Hivites, one of the remaining Canaanite tribes who had chosen to fight Joshua. They wanted to split from the rest of the Hivite nation but erroneously thought that it was too late to make peace with Joshua. They trick Joshua into making a covenant with them by hiding their Canaanite identity and dressing up as weary travellers from a distant land.
After their ruse is discovered, the Jewish people complain that since the Gibeonites had lied the covenant had been made with them under deceit. A principle found throughout Jewish law is that an agreement, whether contractual, marital or religious that is made on false pretences is null and void. The people argued that the Gibeonites remained enemies and prepared to do battle with them.
Joshua however was concerned that while the people were technically correct, the effect of attacking a group who had struck a deal – even falsely – with the Jewish people, could cause a terrible chillul HaShem (desecration of God’s name). Other nations might believe that the Jewish people do not really fear God if they are willing to annul a contract so easily. Therefore, Joshua honoured the covenant with the Gibeonites who were given the lowly jobs of serving as woodchoppers and water drawers for the temple.
Joshua showed that leaders must often make what appear to be painful and unfair concesions in the short term to protect long term interests.