Then Joshua, son of Nun, secretly sent out two spies from Shittim.* The place where the Israelites were camped at the time. “Go and explore Literally, “go about on foot.” the land, especially around Jericho,” he told them. So they went, and stayed at the house of woman named Rahab, a prostitute. There they spent the night.
But the king of Jericho was told, “Look, some Israelites have come here this evening to spy out the land.” So the king of Jericho sent orders to Rahab, telling her, “Hand over the men who came to visit you and stay in your house, for they've come to spy out our whole country.”
The woman had taken the two men and had hidden them. She told the king's messengers, “King's messengers”: implied. “Yes, it's true—the men did come to visit me, but I didn't know where they were from. They left at sundown, just as the city gate was closing. I've no idea where they went. If you're quick, you can chase after them and maybe catch up with them.” (She had taken them up to the roof and hidden them under some bundles of flax that she had lying there.)
The king's messengers went chasing after the men down the road that leads to the Jordan River fords. As soon as the pursuers had left, the city gate was shut behind them.
Before the spies went to sleep, Rachel came up to the roof to talk to them. She told them, “I know that the Lord has given this land to you. We're all terrified of you. Everyone who lives here is dying of fright since you people arrived. 10 We've heard how the Lord dried up the waters of the Red Sea before you when you left Egypt, and what you did to the two kings of the Amorites east of the Jordan, Sihon and Og, whom you completely destroyed. 11 When we heard all this, our courage melted away. Nobody had any fighting spirit left because of you. For the Lord your God is God of heaven above and the earth below. 12 So now promise me in the name of the Lord that because I have acted in good faith to you, then you will do the same for my family. Give me some sign that I can trust you, 13 that you will spare my father and mother and brothers and sisters—and all who are part of their families—that you will save them from death.”
14 “Our lives for yours!” the men told her. “If you don't tell anyone about this, we will treat you honestly and faithfully when the Lord gives us the land.”
15 Then she lowered them down by a rope through the window since the house where she lived was built into the outside of the city wall.
16 “Run to the hills,” she told them. “That way those searching for you won't find you. Stay there three days until they've gone home, and then you can be on your way.”
17 The men had told her, “We will be freed from the promise you made us swear, 18 unless when we enter this land, you hang a scarlet cord in the window through which you lowered us. You must gather together in the house your father and mother and brothers—all the family. 19 If anyone leaves your house and is killed, that's their fault—we're not responsible for their death. But if anyone lays a hand on someone who is inside your house, we take full responsibility for their death. 20 But if you tell anyone about this then we will be freed from the promise you made us swear.”
21 “I agree—may it be as you say,” she replied. She sent them off, and hung a scarlet cord in the window.
22 They went up into the hill country and stayed there three days. The men searching for them looked all along the road, but couldn't find them, so they returned home. 23 Then the two men started back. They came down from the hill country and crossed over the Jordan. They went to Joshua and explained to him all that had happened to them.
24 “The Lord has placed this land in our hands,” they assured him. “All the people who live there are scared to death of us!”

*2:1 The place where the Israelites were camped at the time.

2:1 Literally, “go about on foot.”

2:4 “King's messengers”: implied.