فَغَفَرْنَا لَهُ ذَٰلِكَ ۖ وَإِنَّ لَهُ عِندَنَا لَزُلْفَىٰ وَحُسْنَ مَآبٍ (25)
(38:25) Thereupon We forgave him his shortcoming and indeed (an exalted position of) nearness awaits him, and an excellent resort. *27
*27) This shows that the Prophet David had certainly committed an error, and it was an error which bore some resemblance with the case of the ewes. Therefore, when he gave a decision on it, he at once realized that he was being put to the test. But the nature of the error was not such as could be forgiven, or if forgiven, it would have deposed him from his high rank. AIlah Himself says: "When he fell down prostrate and repented, he was not only forgiven but his high rank in the world and the Hereafter also remained unaffected.