mid-14c., "legendary lizard-like creature that can live in fire," from Old French salamandre (12c.), from Latin salamandra, from Greek salamandra, probably of eastern origin. The application to an actual amphibian is first recorded 1610s.
Aristotle, and especially Pliny, are responsible for the fiction of an animal that thrives in and extinguishes fires. The amphibian lives in damp logs and secretes a milky substance when threatened, but there is no obvious natural explanation its connection with the myth. Also used 18c. for "a woman who lives chastely in the midst of temptations" (after Addison), and "a soldier who exposes himself to fire in battle." To rub someone a salamander was a 19c. form of German student drinking toast (einem einen salamander reiben).