word-forming element meaning "against, in opposition," from Latin adverb and preposition contra "against" (see contra (prep., adv.)). The Latin word was used as a prefix in Late Latin. In French, it became contre- and passed into English as counter-. The Old English equivalent was wiðer (surviving in withers and widdershins), from wið "with, against."
1560s, "recognize as different or distinct from what is contiguous or similar; perceive, make out," from French distinguiss-, stem of distinguer, or directly from Latin distinguere "to separate between, keep separate, mark off, distinguish," perhaps literally "separate by pricking," from assimilated form of dis- "apart" (see dis-) + -stinguere "to prick" (compare extinguish and Latin instinguere "to incite, impel").
Watkins says "semantic transmission obscure;" the sense might be from "pricking out" as the old way to make punctuation in parchment or some literal image, but de Vaan derives the second element from a different PIE root meaning "to push, thrust":
The meanings of ex- and restinguere 'to extinguish' and distinguere seem quite distinct, but can be understood if the root meant 'to press' or 'push': ex-stinguere 'to put a fire out', re-stinguere 'to push back, suppress', and dis-stinguere 'to push apart [thence] distinguish, mark off ....
The suffix -ish is due to the influence of many verbs in which it is the equivalent of Old French -iss-, ultimately from Latin inchoative suffix -iscere (this is also the case in extinguish, admonish, and astonish).
Sense of "to mark or note in a way to indicate difference" is from 1570s; that of "separate from others by some mark of honor or preferment" is from c. 1600. Intransitive meaning "make a distinction, find or show difference (between)" is from 1610s. Related: Distinguishing. The Middle English form of the verb was distinguen (mid-14c.).