1580s, "warehouse, place for storing goods, especially military ammunition," from Middle French magasin "warehouse, depot, store" (15c.), from Italian magazzino, from Arabic makhazin, plural of makhzan "storehouse" (source of Spanish almacén "warehouse, magazine"), from khazana "to store up." The original sense is almost obsolete. Meaning "cartridge chamber in a repeating rifle" is by 1868; that of "a case in which a supply of cartridges is carried" is by 1892.
The meaning "periodical journal containing miscellaneous writings" dates from the publication of the first one, "Gentleman's Magazine," in 1731, which was so called from earlier use of the word for printed lists of military stores and information, or in a figurative sense, from the publication being a "storehouse" of information (originally of books, 1630s).