Old English þegn "military follower, one who holds lands in exchange for military service," also "vassal, retainer, attendant," from Proto-Germanic *thegnas (source also of Old Saxon thegan "follower, warrior, boy," Old Norse þegn "thane, freeman," Old High German thegan, German Degen "thane, warrior, hero"), from PIE *tek-no- (source also of Sanskrit takman "descendant, child," Greek teknon "child"), from root *tek- "to beget, give birth to" (source also of Greek tekos "child, the young of animals," tokos "childbirth, offspring, produce of money, interest"). Also used in Old English for "disciple of Christ." Specific sense of "man who ranks between an earl and a freeman" is late 15c.
The modern spelling is from Scottish, where early 13c. it came to mean "chief of a clan, king's baron," and it has predominated in English probably due to the influence of "Macbeth;" normal orthographic changes from Old English ðegn would have produced Modern English *thain. Some historians now use thegn to distinguish Anglo-Saxon thanes from Scottish thanes.