Can you remember from the dedication of the temple what the substance of the prayer of Solomon and the promise of God was (2nd Chronicles 6 & 1st Kings 8)? Basically, Solomon asked for God to hear the prayers of His people in the future when they encountered hard times and danger. In response to Solomon's prayer, God assured him and his people that He would gladly grant this thing. Now, here, Jehoshaphat came to the temple to cash in this great spiritual check for something that he could spend to purchase his safety and the safety of his people (2nd Chronicles 20:8 - 13).
Jehoshaphat's reign was interrupted by an invasion of Moabites and Ammonites. Now remember, Jehoshaphat had taught the nation truth and had held them accountable for the truth they had been given. So, he had a strong foundation upon which to stand when this crisis arose. Naturally, he and his people came to the sanctuary to ask God for mercy and aid.
Jehoshaphat was a man of faith. But, there was a citizen in his kingdom who had even greater faith. His name was Jahaziel (2nd Chronicles 20:14). Because of the influence of the Spirit of God upon him, he not only believed that God could help them, he was certain that God would indeed intervene on their behalf. He took God's character and His promises at face value and spoke accordingly (2nd Chronicles 20:15-17).
Jehoshaphat not only believed the message of Jahaziel, he called on his people to do the same (II Chronicles 20:20). So, as he and his people worshipped and praised God in song, God delivered them from their enemies. The power of God was so great in their favor that they didn't even have to fight. God turned their enemies against one another and then promptly passed the possessions of those unbelieving gentiles right along to the believing Jews who had called upon Him for help (2nd Chronicles 20:25).