1773, "lively square dance for four couples," consisting regularly of five complete parts, from French quadrille (17c.), originally one of four groups of horsemen in a tournament (a sense attested in English from 1738), from Spanish cuadrilla, diminutive of cuadro "four-sided battle square," from Latin quadrum "a square," related to quattuor "four" (from PIE root *kwetwer- "four"). The craze for the dance hit England in 1816, and it underwent a vigorous revival late 19c. among the middle classes.
Earlier it was the name of a popular card game for four hands, and in this sense it is from French quadrille (1725), from Spanish cuartillo, from cuarto "fourth," from Latin quartus. OED notes it as fashionable ("and was in turn superseded by whist") from 1726, the year of Swift's (or Congreve's) satirical ballad on the craze:
The commoner, and knight, the peer,
Men of all ranks and fame,
Leave to their wives the only care,
To propagate their name;
And well that duty they fulfil
When the good husband's at Quadrille &c.