Attested since 1871. Many sources have been proposed, but none are certain. The Online Etymology Dictionary suggests that it may derive from Bavarian German Haddalump (“ragamuffin”).
According to Herbert Asbury's book The Barbary Coast: An Informal History of the San Francisco Underworld (1933, A. A. Knopf, New York), the word originated in San Francisco from a particular street gang's call to unemployed Irishmen to "huddle 'em" (to beat up Chinese migrants), after which San Francisco newspapers took to calling street gangs "hoodlums".