It is recorded in the second chapter of the book of Joshua that the great leader of that name, following the example of Moses in similar circumstances, ''sent out of Shittim two men to spy secretly, saying, Go view the land" (verse 1; compare Numbers 13:17). Shittim was situated to the east of the Jordan, and the mission of the spies involved their crossing the river into the hostile territory of Canaan.
In due course the spies succeeded in entering the walled city of Jericho, where they lodged at the house of a certain Rahab, according to the Jewish historian Josephus, an innkeeper (Antiquities of the Jews, V:i:2). The Bible bears witness to the courage which she displayed in harboring the Hebrew messengers, not only daring to disregard a royal command (Joshua 2:3), but also braving the traditional penalties for providing aid and comfort to enemy spies in time of war.
Hiding the men under stalks of flax that were laid out to dry on the flat roof of her home. Rahab put the emissaries of the king of Jericho on a false scent. Having thus fended off the immediate danger to her guests, she proceeded to give them valuable information to the effect that the people of Jericho were so demoralized by the news they had heard concerning the Israelite victories, that they were in no mood to resist an attack successfully; moreover she affirmed her conviction that the God of the Hebrews was indeed the true God (verse 11). Readily the spies acceded to her request that when the anticipated conquest of the city was carried out, Rahab and her relatives should be spared, it being arranged that her house should be identified by a "line of scarlet thread" (verse 18) tied in a window. Rahab's final act was to lower the men over the city wall by means of a rope, and so they escaped from Jericho (verse 15) and after hiding in the hills for three days they returned in safety to their commander. It may be added that when eventually the city was taken, the compact with Rahab was observed to the letter.