"act or expression of civility, respect, or regard" (or, as Johnson defines it, "An act, or expression of civility, usually understood to include some hypocrisy, and to mean less than it declares"), 1570s, complement, ultimately from Latin complementum "that which fills up or completes" (see complement, which is essentially the same word), the notion being "that which completes the obligations of politeness."
The spelling of this derived sense shifted in English after c. 1650 to compliment, via French compliment (17c.), which is from Italian complimento "expression of respect and civility," from complire "to fill up, finish, suit, compliment," from Vulgar Latin *complire, for Latin complere "to complete" (see complete (adj.)).
By early 19c. the meaning had been extended to "an expression of praise or admiration. Meaning "a present or favor bestowed, a complimentary gift" is from 1722.
1610s, "pay a compliment to, flatter or gratify by expression of admiration, respect, etc.," from French complimenter, from compliment (see compliment (n.)). By 1690s as "manifest kindness or regard for by a gift or favor." Related: Complimented; complimenting.