I think history shows Muslim countries are better off being ruled by a secular military.
To answer your question, I think NATO only applies if the country is attacked from the outside.
That must be why they intervened in Kosovo and Libya.