Soon after David was anointed king, he encountered spiritual opposition through Joab.
(here is a brief description of Joab from wikipedia)
[Joab, which translates to "The Lord is father," was the nephew of King David, the son of Zeruaiah. He was made the captain of David’s army. He had two brothers, Abishai and Asahel. Asahel was killed by Abner,
for which Joab took revenge by treacherously murdering Abner. However, according to Josephus, in Antiquities, Book 7,
Chapter 1, Joab had forgiven Abner for the death of his brother,
Asahel. The reason being that Abner had slain Asahel honorably in
combat after he had first warned Asahel and had no other choice but to
kill him out of self defense. This battle was part of a civil war
between David and Ishbosheth, the son of Saul. After this battle Abner
switched to the side of David and granted him control over the tribe of
Benjamin. This act put Abner in David’s favor. The real reason that
Joab killed Abner was that he became a threat to his rank of General.]
David had just been anointed king. God was moving. He was experiencing the spiritual victory of feeling God’s presence during an important transition. Then, opposition hits. Joab, who always looked out for his self-interest, took matters into his own hand and killed Abher. Because of this act, David felt weak. When he should have been praising God and preparing his heart to do God’s good work, he had to lament, mourn, and fast.
Whenever you are ready to do God’s work, prepare yourself for spiritual battle. When God is moving, often Satan is right around the corner to distract, frustrate and get us down. So when God is moving in your midst, it’s time to pray all the more.