Dalil

Quran Al-Anfal 8:39

وَقَٰتِلُوهُمۡ حَتَّىٰ لَا تَكُونَ فِتۡنَةٞ وَيَكُونَ ٱلدِّينُ كُلُّهُۥ لِلَّهِۚ فَإِنِ ٱنتَهَوۡاْ فَإِنَّ ٱللَّهَ بِمَا يَعۡمَلُونَ بَصِيرٞ

Translation

And fight against them until there is no fitnah and [until] the religion [i.e., worship], all of it, is for Allāh. And if they cease - then indeed, Allāh is Seeing of what they do.