According to the 1906 Jewish Encyclopedia, ghetto originally meant "the street or quarter of a city in which the Jews were compelled to live, and which was closed every evening by gates." The term is [now] applied to that part of any city or locality chiefly or entirely inhabited by Jews.
"Ghetto" is probably of Italian origin, although no Italian dictionary gives any clue to its etymology. In documents dating back to 1090 the streets in Venice and Salerno assigned to the Jews are called "Judaca" or "Judacaria." Venice and Salerno had ghettos in the eleventh century, and Prague is said to have had one as early as the tenth.
According to Anatoly Libermann in his etymology column for the Oxford University Press, the word's origin remains unclear:
The word "ghetto" is an etymological mystery. Is it from the Hebrew get, or bill of divorce? From the Venetian ghèto, or foundry? From the Yiddish gehektes, "enclosed"? From Latin Giudaicetum, for "Jewish"? From the Italian borghetto, "little town"? From the Old French guect, "guard"? From the Latin for "ribbon"? German for "street"? Latin for "to throw"?
The word's origin is a "stubborn mystery", but its meaning is not: "the quarter in a city, chiefly in Italy, to which the Jews were restricted." (OED)
In the 16th and 17th centuries, cities like Venice, Frankfurt, Prague and Rome forcibly segregated their Jewish populations, often walling them off and submitting them to onerous restrictions. In documents dating back to 1090 the streets in Venice and Salerno assigned to the Jews are called "Judaca" or "Judacaria." At Capua there was a place called "San Nicolo ad Judaicam..." (1375) Hence it is assumed that "Judaicam" became the Italian "Giudeica," and was then corrupted into "ghetto."
The [1906 Jewish Encyclopedia](1906 Jewish Encyclopedia) has a long and interesting article on Jewish ghettos.
As early as 1908, "ghetto" was sometimes used metaphorically to describe slum areas that weren't mandated by law but that were limited to a single group of people because of other constraints. That year, Jack London wrote of "the working-class ghetto."