mid-15c., countre part "duplicate of a legal document," from Middle French contrepartie, from contre "facing, opposite" (see contra (prep., adv.)) + partie "copy of a person or thing," originally fem. past participle of partir "to divide" (see party (n.)).
Meaning "corresponding part, part that answers to another" is from 1630s. Sense of "person or thing exactly resembling another" is from 1670s; that of "person or thing serving as the equivalent of another in a different context" is by 1903.