early 15c. (implied in deteined), "keep back or away, withhold," from Old French detenir "to hold off, keep back" (12c.), from Latin detinere "hold off, keep back," from de "from, away" (see de-) + tenere "to hold," from PIE root *ten- "to stretch."
Legal sense of "to hold in custody" is from late 15c. (late 13c. in Anglo-French). Meaning "keep or restrain from proceeding" is from 1590s. Modern spelling is 17c., from influence of contain, retain, etc. Related: Detained; detaining.