Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:16:125

Invite to the way of your Lord with wisdom and good instruction, and argue with them in a way that is best. Indeed, your Lord is most knowing of who has strayed from His way, and He is most knowing of who is ˹rightly˺ guided.  

Call, mankind, O Muhammad (s), to the way of your Lord, ˹to˺ His religion, with wisdom, ˹with˺ the Qur’ān, and fair exhortation, its ˹the Qur’ān’s˺ fair exhortations, or with gentle words, and dispute with them by way of that which, that is, by way of that ˹manner of˺ disputation which, is best, such as calling ˹them˺ to God by way of His signs and calling ˹them˺ to His definitive arguments. Truly your Lord knows best, that is, He is fully knowledgeable ˹of˺, those who stray from His way and He knows best those who are guided, and will requite them — this was ˹revealed˺ before the command to fight ˹them˺.
القرآن:١٦:١٢٥

ادْعُ إِلَىٰ سَبِيلِ رَبِّكَ بِالْحِكْمَةِ وَالْمَوْعِظَةِ الْحَسَنَةِ ۖ وَجَادِلْهُمْ بِالَّتِي هِيَ أَحْسَنُ ۚ إِنَّ رَبَّكَ هُوَ أَعْلَمُ بِمَنْ ضَلَّ عَنْ سَبِيلِهِ ۖ وَهُوَ أَعْلَمُ بِالْمُهْتَدِينَ  

{ادع} الناس يا محمد {إلى سبيل ربك} دينه {بالحكمة} بالقرآن {والموعظة الحسنة} مواعظه أو القول الرقيق {وجادلهم بالتي} أي بالمجادلة التي {هي أحسن} كالدعاء إلى الله بآياته والدعاء إلى حججه {إن ربك هو أعلم} أي عالم {بمن ضل عن سبيله وهو أعلم بالمهتدين} فيجازيهم وهذا قبل الأمر بالقتال ونزل لما قتل حمزة ومثِّل به فقال ﷺ وقد رآه: لأمثلن بسبعين منهم مكانك.

See similar narrations below:

Collected by Qurʾān
quran:68:7

Indeed, your Lord is most knowing of who has gone astray from His way, and He is most knowing of the ˹rightly˺ guided.  

Assuredly your Lord knows best those who stray from His way, and He knows best those who are guided, to Him.
القرآن:٦٨:٧

إِنَّ رَبَّكَ هُوَ أَعْلَمُ بِمَنْ ضَلَّ عَنْ سَبِيلِهِ وَهُوَ أَعْلَمُ بِالْمُهْتَدِينَ  

{إن ربك هو أعلم بمن ضل عن سبيله وهو أعلم بالمهتدين} له وأعلم بمعنى عالم.