1610s, " to enter or be put in rivalry with," from Middle French compéter "be in rivalry with" (14c.), or directly from Late Latin competere "strive in common, strive after something in company with or together," in classical Latin "to meet or come together; agree or coincide; to be qualified," from com "with, together" (see com-) + petere "to strive, seek, fall upon, rush at, attack" (from PIE root *pet- "to rush, to fly").
According to OED, rare 17c., revived from late 18c. in sense "to strive (alongside another) for the attainment of something" and regarded early 19c. in Britain as a Scottish or American word. Market sense is from 1840s (perhaps a back-formation from competition); athletics sense attested by 1857. Intransitive use is by 1974. Related: Competed; competing.