late 13c., "a part of a body where two bones meet and move in contact with one another," from Old French joint "joint of the body" (12c.), from Latin iunctus "united, connected, associated," past participle of iungere "join" (see jugular). Related: Joints. Slang meaning of "place, building, establishment" (especially one where persons meet for shady activities) first recorded 1877, American English, from an earlier Anglo-Irish sense (1821), perhaps on the notion of a side-room, one "joined" to a main room. The original U.S. sense was especially of "an opium-smoking den."
Meaning "marijuana cigarette" (1938) is perhaps from notion of something often smoked in common, but there are other possibilities; earlier joint in drug slang meant "hypodermic outfit" (1935). Meaning "prison" is attested from 1953 but probably is older. Out of joint in the figurative sense is from early 15c. (literally, of bone displacement, late 14c.).