2 Samuel 12:16

David therefore besought God for the child; and David fasted, and went in, and lay all night upon the earth.

The verse belongs to the time when David, after ruling with fair justice for all his people and winning the nation's trust and loyalty by integrity, turned away from God and yielded to evil while still holding the position and authority God had given him. In that fall he arranged the death of Uriah by making him carry his own death order to Joab, instructing Joab to place Uriah at the front of the fiercest fighting and then withdraw from him so he would be struck down. Joab, already guilty of an earlier deliberate killing, readily obeyed, so that Uriah fell at the hands of enemy forces, by the sword of the children of Ammon.

Joab then sent a messenger with a carefully worded report that avoided implicating Joab or the king and noted only that Uriah had died as well. David replied that the loss should not displease Joab since battle claims one person as well as another, and told him to strengthen the attack against the city and take courage. In ordering Uriah's death David used power given by God to command what was contrary to God's law and to claim an obedience that would endanger the soul of the one who yielded it, and Joab broke God's law because his allegiance was to the king rather than to God. Power from God is to be exercised only in harmony with divine law, so when a ruler commands what breaks God's law it becomes sin to obey. By abandoning God's teachings in this affair David stained his reputation.

The verse shows David pleading with God for his child's life by fasting and lying on the ground through the night, laying aside his royal robes and crown in deep grief and continuing to pray while the child lived in hope that humiliation and repentance might turn aside the judgment. His intercession for his sick child involved fasting and lying prostrate for seven days and nights. David's repentance was sincere and God forgave him, yet God still punished the transgression and David lost the child. When the child died David ended his pleading and mourning, rising and submitting to God's decision, and he found comfort by trusting in God's mercy.