Two men have been sent by Joshua to secretly check out the city of Jericho to get a feel for what the Israelites would face when they got there. Unfortunately, either they weren’t very good at covert operations, or they just stood out as “not one of us,” and the king of Jericho found out about them. He sent soldiers to the house of Rahab, where he had been told the men were staying.
When Rahab heard that soldiers were coming for the men, she took them up to the roof of her house and hid them under a pile of flax stocks. Then she told the soldiers that, yes, the men had been there, but they had left just before the city gates closed for the night, and she had no idea what direction they had gone. The soldier took off in hot pursuit.
Yep. She lied, but why? She explained her reasoning to the spies:
“I know that the Lord has given you this land and that a great fear of you has fallen on us, so that all who live in this country are melting in fear because of you. We have heard how the Lord dried up the water of the Red Sea for you when you came out of Egypt, and what you did to Sihon and Og, the two kings of the Amorites east of the Jordan, whom you completely destroyed. When we heard of it, our hearts melted in fear and everyone’s courage failed because of you, for the Lord your God is God in heaven above and on the earth below” (Joshua 2:9-11).
She then extracted a promise from the spies that when Israel came to take Jericho they would treat her and her family kindly because of the kindness she had shown to them. They agreed, and she helped them escape the city by means of a rope out her window. They told her to be sure the rope (a scarlet one) was hanging out the window when they came, and that all her family was to be there in her house. She did, they kept their promise, and Rahab earned a place in biblical history.
There’s a whole lot more to the story that you can read in Joshua chapters 2 and 6. It’s a great story that, among other things, shows that the pagan people who occupied the Promised Land clearly understood that there was something special about Israel’s God.
A few interesting things come up in regard to this story. First is Rahab’s identity as a prostitute. Some, including the historian Josephus, identify her instead as an “innkeeper,” apparently an alternate meaning of the work. The bottom line, regardless of her occupation, is that she was a pagan who worshiped other gods, and yet, because of the clear evidence of the power of Israel’s God, she chose to weigh in and fight on His side. She made her allegiance to Israel’s God clear, and because of that she was welcomed into the nation. Joshua 6:25 says, “But Joshua spared Rahab the prostitute, with her family and all who belonged to her, because she hid the men Joshua had sent as spies to Jericho—and she lives among the Israelites to this day.”
Next, we must briefly address her lie. Was it justified because it resulted in saving the lives of the spies and paving the way for Israel’s victory over Jericho? Sadly, no. Walter Kaiser explains:
“Rahab’s lie,… cannot be so easily dismissed. She said, ‘I don’t know which way they went.’ That was palpably false. Romans 3:8 warns us not to say, ‘Let us do evil that good may result.’ Neither should we argue, especially from a descriptive or a narrative passage, that a text validates deceit under certain conditions.
“The so-called dutiful lie ignores how precious the truth is in God’s sight. Even lies told for very good purposes are not free from divine disapproval. Moreover, even if in the de facto providence of God, Rahab’s untruth allowed the two spies to escape harm, this does not therefore justify such a method. God is not reduced to unholy acts to fulfill his will. At most God allowed his purposes to be fulfilled in this most unusual manner, because his grace can operate in spite of the sinful maneuverings of men and women. Untruth cannot be vindicated simply because it is closely tied to the total result.”
And finally, Rahab rated three mentions in the New Testament. First of course is her mention in the genealogy of Jesus in Matthew 1:5: “Salmon the father of Boaz, whose mother was Rahab,…”
Then she is mentioned in the “Hall of Fame” chapter, Hebrews 11:31: “By faith the prostitute Rahab, because she welcomed the spies, was not killed with those who were disobedient.”
And finally, James used Rahab as an example in his argument of faith vs. works (James 2:25): “In the same way, was not even Rahab the prostitute considered righteous for what she did when she gave lodging to the spies and sent them off in a different direction?” Rahab is another example of a non-Jew who earned her place in God’s kingdom because of her faith, however faint and undeveloped, in the God of Israel.
 W.A. Criswell picks up the imagery of the scarlet rope hung from the window is his The Scarlet Thread through the Bible, in which he traces the history of redemption through the blood of Jesus. You can find a PDF copy here: https://www.gospelproject.com/wp-content/uploads/tgp2018/2018/04/The-Scarlet-Thread-Criswell.pdf. It’s worth a read.
 Walter C. Kaiser, Jr., P.H. Davids, F.F. Bruce, & M.T. Brauch, M. T., Hard Sayings of the Bible (Downers Grove, IL: InterVarsity, 1996), pp. 181–182.