1550s, originally "to turn up one's nose, sneer at," then "to rap or flick, as with the fingers" (1560s). The noun is first attested 1540s, from the verb, with the meaning "stroke of wit." It's possible that the original word was imitative, along the lines of flip (v.), but there seems to be some influence from flit, such as in the flirt sense of "to move in short, quick flights," attested from 1580s.
Meanwhile flirt (n.) had come to mean "a pert young hussey" [Johnson] by 1560s, and Shakespeare has flirt-gill (i.e. Jill) "a woman of light or loose behavior," while flirtgig was a 17c. Yorkshire dialect word for "a giddy, flighty girl." All or any of these could have fed into the main modern verbal sense of "play at courtship" (1777), which also could have grown naturally from the earlier meaning "to flit inconstantly from object to object" (1570s), perhaps influenced by Old French fleureter "talk sweet nonsense," also "to touch a thing in passing," diminutive of fleur "flower" and metaphoric of bees skimming from flower to flower.
The noun meaning "person who flirts" is from 1732. The English word also is possibly related to East Frisian flirt "a flick or light blow," and flirtje "a giddy girl." French flirter "to flirt" is a 19c. borrowing from English. Related: Flirted; flirting.