Surah Al-Baqarah 2:251
فَهَزَمُوهُم بِإِذْنِ ٱللَّهِ وَقَتَلَ دَاوُۥدُ جَالُوتَ وَءَاتَىٰهُ ٱللَّهُ ٱلْمُلْكَ وَٱلْحِكْمَةَ وَعَلَّمَهُۥ مِمَّا يَشَآءُ ۗ وَلَوْلَا دَفْعُ ٱللَّهِ ٱلنَّاسَ بَعْضَهُم بِبَعْضٍ لَّفَسَدَتِ ٱلْأَرْضُ وَلَـٰكِنَّ ٱللَّهَ ذُو فَضْلٍ عَلَى ٱلْعَـٰلَمِينَ
So they defeated them by permission of Allāh, and David killed Goliath, and Allāh gave him the kingship and wisdom [i.e., prophethood] and taught him from that which He willed. And if it were not for Allāh checking [some] people by means of others, the earth would have been corrupted, but Allāh is the possessor of bounty for the worlds.
Translation: Saheeh International
Tafsir
And they routed they broke them by the leave of God by His will and David who was among the ranks of Saul’s army slew Goliath; and God gave him David the kingship over the Children of Israel and Wisdom prophethood after the death of Samuel and Saul and the combination of kingship and prophethood had never come to …
Excerpt from Tafsir al-Jalalayn, commentary on 2:251, via Quran.com. The reader has the full commentary and 9 more tafsirs.