Probably partly borrowed from Latinmedius as a semi-learned form or modified from an existing inherited early Old Spanish equivalent, presumably *meo or *meyo, to be closer to the Latin origin (possibly in order to avoid a phonetic similarity with the vulgar verb mear ‎(“to piss”))[1]. Compare Portuguese meio, which retained its original inherited form. The sense of "medium" is taken from Latin medium.