1875, from Italian Mafia "Sicilian secret society of criminals" (the prevailing sense outside Sicily), earlier, "spirit of hostility to the law and its ministers." A member is a mafioso (1870), fem. mafiosa, plural mafiosi, and this may be the older word in this sense. Arabic is often cited as the ultimate source (the Arabs ruled Sicily for more than two centuries in the Middle Ages), but which Arabic word is a matter of disagreement.
The most likely origin of the actual meaning of mafioso and its derivative mafia — as suggested by the nineteenth-century Sicilian ethnographer Giuseppe Pitrè — is a play by Placido Rizzoto, I Mafiusi della Vicaria, first performed in 1863. ... The play concerns a group of prisoners in the Palermo jail who command particular respect: although individualistic and quarrelsome, they are members of an association with distinct patterns of behavior (including an initiation ritual) and a hierarchy, which claims it can influence the political and administrative system of the island. [Diego Gambetta, "The Sicilian Mafia," Harvard, 1993]
The immediate source of mafioso, then, would be 19c. Sicilian mafiusu, "signifying a bully, arrogant but also fearless, enterprising, and proud" [Gambetta], who favors as the Arabic source an adjective from marfud "rejected."