c. 1200, "stoneworker" (as a surname, early 12c.), from Old French masson, maçon "stone mason" (Old North French machun), probaby from Frankish *makjo or some other Germanic source (compare Old High German steinmezzo "stone mason," Modern German Steinmetz, second element related to mahhon "to make;" from PIE root *mag- "to knead, fashion, fit."
But it also might be from, or influenced by, Medieval Latin machio, matio (7c.) which is said by Isidore to be derived from machina (see machine). The medieval word also might be from the root of Latin maceria "wall." Meaning "a Freemason" is attested from early 15c. in Anglo-French.