The only free and comprehensive online etymological dictionary of the Spanish language
mayor (Adjective) "larger," "older"

12th cent. From Latin maior 'id.' From Proto-Italic *mag-jo- "greater." From Proto-Indo-European *mǵ-i̯ó- 'id.' From *meǵ- "great." See also más.

As for the origin of the surname: the Mayor was the master of a farmhouse or estate, thus called during the Medieval period.

Romance: Western Vulgar Latin: Asturian mayor, Portuguese maior, Galician maior, Catalan major, French majeur, maire, Italian maggiore; Eastern Vulgar Latin: Romanian maior ; Sardinian: magiori

Indo-European: Celtic: Gaulish Magios (name) "great," Middle Irish maige "large;" Gothic: Gothic mikils "large," Old Norse mikill 'id.,' Old High German mihhil 'id.,' Old Saxon mikil 'id.,' Old English micel 'id.' (Middle English muchel, English much); Albanian: madh "large;" Hellenic: Ancient Greek μέγας (mégas) "large;" Armenian: mec "large;" Indo-Iranian: Sanskrit máhi- "large," Avestan mazōi "big;" Tocharian: A māk "many," B māka 'id.;' Anatolian: Hittite mekk- "much," Cuneiform Luwian maia- "many"