The Holy Quran: 2:251 says

Then they defeated them with the Authority of Allah and David killed Goliath and Allah gave him the kingdom and wisdom and taught him of the things He willed. And were it not that Allah defends mankind, some of them by means of the others, the earth would be full of disorder. But Allah is the Bestower of Grace on the people of the world. (The Holy Quran , Surah 2 verse 251).

