David penned this psalm after a battle with Edom. However, the psalm has the perspective before the battle took place. Edom had invaded Israel will David was away and brought destruction to the region. David had been winning victories far away, but now there was an obvious lose at home. David recognized the failure as God's displeasure with the nation and with himself. David called upon God to go with the nation again. God made clear that He was in control of the nations. His nation just needed to respond in repentance for Him to help.