The military 's image had already been tarnished by allegations it was secretly planning to depose Erdogan 's elected government for undermining secularism in this predominantly Muslim but officially secular country .