A corruption of “English.” The word got into general use thus: In 1713 one Jonathan Hastings, a farmer at Cambridge, in New York, used the word as a puffing epithet, meaning genuine, American-made, what cannot be surpassed, etc.; as, a “Yankee horse,” “Yankee cider,” and so on. The students of the college, catching up the term, called Hastings “Yankee Jonathan.” It soon spread, and became the jocose pet name of the New Englander. Since then the term has been extended to any American of the Northern States. (Indian corruption of Anglais or English, thus: Yengees, Yenghis, Yanghis, Yankees.)
Nankee Doodle came to town upon his little pony, Stuck a feather in his hat, and called it macaroni.
The brigade under Lord Percy marched out of Boston playing this air “by way of contempt,” but were told they should dance to it soon in another spirit.
Source: Dictionary of Phrase and Fable, E. Cobham Brewer, 1894