1 Kings 8:35–36 (ESV)

35 “When heaven is shut up and there is no rain because they have sinned against you, if they pray toward this place and acknowledge your name and turn from their sin, when you afflict them,

Solomon moved to another example of when prayer toward the temple would be necessary. The situation he had in mind was the experience of a drought. Again, we find the phrase because they have sinned. The covenant people were to learn a lesson here; their Lord was the One who controlled all the forces of nature. Therefore, when a drought came, they could safely conclude that their behaviour had something to do with it.

If they recognized the guilt of their sin, which Solomon said was to be understood as acknowledging the name of God, then he entreated the Lord to hear their prayer and give them the desired rain.

If the same question arises at this point as it did in the prayer that concerned the defeat of the army, then the answer is the same. Those in covenant relationship with the Lord might very well expect a particular chastisement of drought to be visited upon them, but for other nations this might be simply an example of the curse under which creation groans because of the sin, not of the covenant people specifically, but of all humanity.