"doctrine or opinion at variance with established standards" (or, as Johnson defines it, "an opinion of private men different from that of the catholick and orthodox church"), c. 1200, from Old French heresie, eresie "heresy," and by extension "sodomy, immorality" (12c.), from Latin hæresis, "school of thought, philosophical sect." The Latin word is from Greek hairesis "a taking or choosing for oneself, a choice, a means of taking; a deliberate plan, purpose; philosophical sect, school," from haireisthai "take, seize," middle voice of hairein "to choose," a word of unknown origin, perhaps cognate with Hittite šaru "booty," Welsh herw "booty;" but Beekes offers "no etymology."
The Greek word was used by Church writers in reference to various sects, schools, etc. in the New Testament: the Sadducees, the Pharisees, and even the Christians, as sects of Judaism. Hence the meaning "unorthodox religious sect or doctrine" in the Latin word as used by Christian writers in Late Latin. But in English bibles it usually is translated sect. Transferred (non-religious) use in English is from late 14c.