mid-13c., "shelter for the needy," from Old French hospital, ospital "hostel, shelter, lodging" (Modern French hôpital), from Late Latin hospitale "guest-house, inn," noun use of neuter of Latin adjective hospitalis "of a guest or host" (as a noun, "a guest; the duties of hospitality"), from hospes (genitive hospitis) "guest; host;" see host (n.1).
The sense of "charitable institution to house and maintain the needy" in English is from early 15c.; the meaning "institution for sick or wounded people" is recorded by 1540s. The same word, contracted, is hostel and hotel. The sense shift in Latin from duties to buildings might have been via the common term cubiculum hospitalis "guest-chamber." The Latin adjective use continued in Old French, where ospital also could mean "hospitable" and ospitalite could mean "hospital."