The head of Egypt's Al-Azhar university has been replaced after describing a leading Islamic researcher as an apostate.