1. Joshua 2:2 (ESV)
  2. Exposition

How did the king find out that the spies were in the city?

Joshua 2:2 (ESV)

2 And it was told to the king of Jericho, “Behold, men of Israel have come here tonight to search out the land.”

Given the fact that Joshua and the tribes of Israel were encamped not far from Jericho, the king and his soldiers were probably on the lookout for any strange men. They would have been on the alert. Any news of new arrivals in the city would have quickly been told to the king and his guards.