mid-14c., "opposite, opposed, at the opposite point or in the opposite direction; extremely unlike, most unlike," from Anglo-French contrarie, Old French contrarie, and directly from Latin contrarius "opposite, opposed; contrary, reverse," from contra "against" (see contra). Meaning "given to contradiction, perverse, intractable" is from late 14c.; sense of "adverse, unfavorable" is from late 14c. Related: Contrarily.
As a noun from late 13c., "one of a pair of characters, propositions, terms, etc., the most different possible within the same class." The phrase on the contrary "in precise or extreme opposition to what has been said" is attested from c. 1400 as in the contrary.
If we take the statement All men are mortal, its contrary is Not all men are mortal, its converse is All mortal beings are men, & its opposite is No men are mortal. The contrary, however, does not exclude the opposite, but includes it as its most extreme form. Thus This is white has only one opposite, This is black, but many contraries, as This is not white, This is coloured, This is dirty, This is black; & whether the last form is called the contrary, or more emphatically the opposite, is usually indifferent. But to apply the opposite to a mere contrary (e.g. to I did not hit him in relation to I hit him, which has no opposite), or to the converse (e.g. to He hit me in relation to I hit him, to which it is neither contrary nor opposite), is a looseness that may easily result in misunderstanding; the temptation to go wrong is intelligible when it is remembered that with certain types of sentence (A exceeds B) the converse & the opposite are identical (B exceeds A). [Fowler]