mid-15c., "a keeping, a guarding, safe-keeping, protection, defense," from Latin custodia "guarding, watching, keeping," also "prison," from custos (genitive custodis) "guardian, keeper, protector," from PIE root *(s)keu- "to cover, conceal." Meaning "restraint of liberty, confinement" is from 1580s.