Two men climbed into his prayer chamber with a dispute. Dawud realised it was a test and sought forgiveness.
Qur'an: Two disputants climbed the wall of his prayer chamber. One said: 'This is my brother. He has ninety-nine ewes and I have one, and he said: give it to me' (38:21–23).
Qur'an: Dawud judged that the other had wronged him. Then he realised that Allah had tested him, asked forgiveness, and bowed down in repentance (38:24).
Qur'an: 'O Dawud, We have made you a successor on earth, so judge between people in truth and do not follow desire' (38:26).