late 14c., nasti, "foul, filthy, dirty, unclean," literally or figuratively, a word of uncertain origin. Middle English Compendium says from Old Norse (compare Swedish dialectal and Danish naskug, nasket "dirty, nasty") with Middle English adjectival suffix -i. There was a variant nasky in early Modern English.
Barnhart suggests Old French nastre "miserly, envious, malicious, spiteful," shortened form of villenastre "infamous, bad," from vilain "villain" (see villain) + -astre, pejorative suffix, from Latin -aster. Another alternative etymology [mentioned in OED] is from Dutch nestig "dirty," literally "like a bird's nest."
From c. 1600 as "indecent, obscene" ("morally filthy"). Of weather, "foul, stormy," from 1630s; of things generally, "unpleasant, offensive; troublesome, annoying," from 1705. Of people, "ill-tempered, mean," from 1825. The noun meaning "something nasty" is from 1935. Related: Nastily; nastiness.
Nasty, in England frequently meaning ill-tempered or cross-grained (Slang Dictionary, p. 186), and in this sense admitted into good society, denotes in America something disgusting in point of smell, taste, or even moral character, and is not considered a proper word to be used in the presence of ladies. [M. Schele De Vere, "Americanisms," 1872]