When the king of Jericho learns that Israelite spies have infiltrated his city, he sends a direct demand to Rahab to surrender them. This confrontation reveals the complex legal customs of the era as well as the layers of deception employed by the spies.
Instead of simply dispatching his police to break down the door and arrest the men by force, the king requests that Rahab bring them out herself. This approach stems from the gentile laws of the time, which strictly forbade rulers or law enforcement from entering places of idol worship to extract individuals condemned to death. Prevented by law from entering her home, the king has no choice but to demand her cooperation [אהבת יהונתן].
The king's message highlights a careful distinction between the men coming to Rahab personally and coming to her house, exposing the spies' cover story. He explains to Rahab that while the men presented a false front of seeking her out for immoral purposes, their true, hidden objective was using her house as a base to uncover the region's secrets [מלבי"ם]. This fabricated excuse is exactly what allows Rahab to later defend herself to the authorities. She could plausibly claim she believed they had come solely for her services and was entirely unaware of their true identities or mission [חומת אנך]. The true nature of their task is compared to digging, illustrating how they are actively searching and exploring the territory to expose its hidden vulnerabilities [רד"ק, ביאור שטיינזלץ].
The king specifically notes that the spies intend to search the entire land, rather than just the city of Jericho. This detail explains his urgency in demanding their immediate extraction. Under different circumstances, the king might have chosen to leave the spies in Rahab's house, hoping they would succumb to sin. Such a moral failure would anger God, stripping the spies of His Divine protection and ensuring their defeat at Jericho. However, because their mission targets the entire country, the king realizes that even if they sin and lose His Divine help in Jericho, they would still remain a formidable military threat to the rest of the land where no such sin occurred. Therefore, leaving them alone is too great a risk, forcing him to demand their immediate surrender [אהבת יהונתן].