1 Kings 8:41 “As for the foreigner who does not belong to your people Israel but has come from a distant land because of your name— 42 for they will hear of your great name and your mighty hand and your outstretched arm—when they come and pray toward this temple, 43 then hear from heaven, your dwelling place. Do whatever the foreigner asks of you, so that all the peoples of the earth may know your name and fear you, as do your own people Israel, and may know that this house I have built bears your Name.

44 “When your people go to war against their enemies, wherever you send them, and when they pray to the Lord toward the city you have chosen and the temple I have built for your Name, 45 then hear from heaven their prayer and their plea, and uphold their cause.

46 “When they sin against you—for there is no one who does not sin—and you become angry with them and give them over to their enemies, who take them captive to their own lands, far away or near; 47 and if they have a change of heart in the land where they are held captive, and repent and plead with you in the land of their captors and say, ‘We have sinned, we have done wrong, we have acted wickedly’; 48 and if they turn back to you with all their heart and soul in the land of their enemies who took them captive, and pray to you toward the land you gave their ancestors, toward the city you have chosen and the temple I have built for your Name; 49 then from heaven, your dwelling place, hear their prayer and their plea, and uphold their cause. 50 And forgive your people, who have sinned against you; forgive all the offenses they have committed against you, and cause their captors to show them mercy; 51 for they are your people and your inheritance, whom you brought out of Egypt, out of that iron-smelting furnace.

52 “May your eyes be open to your servant’s plea and to the plea of your people Israel, and may you listen to them whenever they cry out to you. 53 For you singled them out from all the nations of the world to be your own inheritance, just as you declared through your servant Moses when you, Sovereign Lord, brought our ancestors out of Egypt.”


This is from the workingpreacher.org site.

Finally, it is important to note that we who are Gentiles are also in this text. In verses 41-43, Solomon speaks of the "foreigner" who will pray "towards this house." He asks God to heed the prayer of (even) that foreigner "so that all the peoples of the earth may know your name and fear you, as do your people Israel" (8:43). We Gentiles are included in God's mercy and have access to God even at this early stage of Israel's history. Such inclusion is reason for thanksgiving and humility.

So that's the key in this theocracy. Even foreigners could participate with the leader of this theocracy. Everyone... who wanted to participate... was welcome to do so. That's what Solomon had in mind.

This is from the blueletterbible.org site.

Solomon prayed with the idea that God should answer the prayers for victory made in foreign lands towards the temple, but only when they battle as God sent them. This was not a blanket request for blessing on every military adventure.

When they sin against You (for there is no one who does not sin): This is a succinct Old Testament statement of the principle most clearly stated in Romans 3:23: for all have sinned and fall short of the glory of God.

Solomon also asked God to hear Israel's prayer from captivity in a foreign land. This recognized that the God of the Temple could answer prayers made away from the temple.