What is the origin of hex?

Hex “to bewitch” is a borrowing via Pennsylvania Dutch from German hexen, related to the noun Hexe “witch.” Hexe is a cognate of the English word hag “witch, sorceress; ugly old woman,” and the two are shortened from Old High German hagazussa and Old English hægtesse, respectively. Though hex and hag have long had negative connotations in English because of their magical associations, theories about their origin are far less biased; the haga-/hæg- element may derive from a root meaning “able, skilled” or could be connected to hawthorn, hay, and hedge, thereby reflecting a historical link between plants and sorcery. The -zussa/-tesse element, in turn, may be related to a variety of words in the Indo-European language family with meanings such as “fairy,” “ghost,” and “demon.” Hex was first recorded in English in the 1820s.