1680s, "a blunder in fencing," from French contre-temps "motion out of time, unfortunate accident, bad times" (16c.), from contre, an occasional, obsolete variant of contra (prep.) "against" (from Latin contra "against;" see contra (prep., adv.)) + tempus "time" (see temporal).
Meaning "an unfortunate accident, an unexpected or embarrassing event" is from 1802; as "a dispute, disagreement," from 1961. It also was used as a ballet term (1706).