The only free and comprehensive online etymological dictionary of the Spanish language
gratis (Adjective, Adverb) "free," "freely"
Early 17th cent. Borrowed from Latin gratis 'id.,' earlier gratiis "by grace," "by friendship;" ablative of gratia "grace" (see gracia).
Indo-European
Romance
Portuguese grátis, Catalan gratis, French gratis, Italian gratis, Romanian gratis

On the evolution of gratis, consider the parallel remarks of Benveniste on its development from Latin into French: "Lat. gratiosus can mean “who feels gratitude” and “held in favor, popular” and also “what shows favor, gracious.” With the same specialization, gratiis contracted to gratis, which French has borrowed from Latin, means “without paying”: gratis habitare ‘to live for nothing, without paying rent’. In this way there appears in the use of gratia a new sense, that of a service provided or obtained “by grace and favor, to give pleasure.”" ~ E. Benveniste, Indo-European Language and Society (1973)