Quran 38: 17-29:
Sahih International: Be patient over what they say and remember Our servant, David, the possessor of strength; indeed, he was one who repeatedly turned back [to Allah]. (verse 17)
Sahih International: Indeed, We subjected the mountains [to praise] with him, exalting [Allah] in the [late] afternoon and [after] sunrise. (verse 18)
Sahih International: And the birds were assembled, all with him repeating [praises]. (verse 19)
Commentary of verse 19:
David was known for his poetic expressions of faith. The Psalms (Zabur) is considered a masterwork of religious and spiritual expression. Even the birds, we are told, sang the praises of God when he did. See Psalm 148:1-14.
Sahih International: And We strengthened his kingdom and gave him wisdom and discernment in speech. (verse 20)
Commentary of verse 20:
The word used here, al-khitab, is the same one from which the name of the Friday sermon given in mosques is derived, i.e., the khutbah.
Sahih International: And has there come to you the news of the adversaries, when they climbed over the wall of [his] prayer chamber – (verse 21)
Sahih International: When they entered upon David and he was alarmed by them? They said, “Fear not. [We are] two adversaries, one of whom has wronged the other, so judge between us with truth and do not exceed [it] and guide us to the sound path. (verse 22)
Sahih International: Indeed this, my brother, has ninety-nine ewes, and I have one ewe; so he said, ‘Entrust her to me,’ and he overpowered me in speech.” (verse 23)
Sahih International: [David] said, “He has certainly wronged you in demanding your ewe [in addition] to his ewes. And indeed, many associates oppress one another, except for those who believe and do righteous deeds – and few are they.” And David became certain that We had tried him, and he asked forgiveness of his Lord and fell down bowing [in prostration] and turned in repentance [to Allah]. (verse 24)
Commentary of verse 24:
When the Prophet recited this verse in a gathering, he prostrated, and the people in the audience did so, likewise. On another occasion he recited it, and the people stood up to prostrate, but he said, “This is the repentance of a prophet, but I see you’re preparing to prostrate.” Then he came down from his pulpit and prostrated. (Abu Dawud) All schools of thought are in agreement that when anyone reads this verse [38:24] that he or she should prostrate and praise God, also.
Sahih International: So We forgave him that; and indeed, for him is nearness to Us and a good place of return. (verse 25)
Sahih International: [We said], “O David, indeed We have made you a successor upon the earth, so judge between the people in truth and do not follow [your own] desire, as it will lead you astray from the way of Allah.” Indeed, those who go astray from the way of Allah will have a severe punishment for having forgotten the Day of Account. (verse 26)
Commentary of verse 26:
The word khalifah, or caliph, means either a successor, a caretaker, or a responsible ruler, depending on the context.
The citizens of an Islamic state have the right to question their ruler and seek his judgments. One early caliph of Islam, Al-Waleed ibn ‘Abdul Malik once asked a scholar named Ibrahim Abu Zur’ah, “Does anyone have the right to question the caliph? You’ve read the first scripture (the Bible) and the Qur’an, and you’ve understood them both.” Abu Zur’ah replied, “May I speak freely, Commander of the Faithful?” He said, “Speak freely, for you are under God’s protection.” Abu Zur’ah said, “Commander of the Faithful, are you more beloved to God or is David, peace be upon him? For God granted prophethood to him and allowed him to rule, then He gave him a warning in His Book…” (Then he quoted verse 26). (Ibn Abi Hatim)
Sahih International: So they defeated them by permission of Allah , and David killed Goliath, and Allah gave him the kingship and prophethood and taught him from that which He willed. And if it were not for Allah checking [some] people by means of others, the earth would have been corrupted, but Allah is full of bounty to the worlds.
The following excerpt is taken from “The Study Quran” under the commentary of the above verse:
The Quranic account here assumes a general knowledge of the story of Saul, David, and Goliath: though a young boy, David is appointed by Saul to face Goliath as the Israelites’ champion and fells the huge warrior with a stone from his sling (cf. 1 Samuel 17). He was given wisdom, meaning that, as a major prophet in the Islamic tradition, he inherited the prophethood of Samuel, and sovereignty, meaning he inherited the kingship of Saul (Ṭ). For further description of David and his prophethood and reign, see 38:17–29.
Emerick, Yahiya. The Meaning of the Holy Qur’an in Today’s English (p. 827). Unknown. Kindle Edition.
Nasr, Hossein (2015). Study Quran. http://www.islamicweblibrary.com/wp-content/uploads/2020/04/TheStudyQuran.pdf