Old English borgian "to lend, be surety for," from Proto-Germanic *burg- "pledge" (source also of Old English borg "pledge, security, bail, debt," Old Frisian borgia "borrow, take up money," Old Norse borga "to become bail for, guarantee," Middle Dutch borghen "to protect, guarantee," Old High German boragen "to beware of," German borgen "to borrow; to lend"), which is, according to Watkins, from PIE root *bhergh- (1) "to hide, protect."
Sense shifted in Old English to the modern one, "take or obtain (something) on pledge to return it or security given," apparently on the notion of collateral deposited as security for something borrowed. Figurative use from early 13c. As an operation in subtraction, 1590s. Related: Borrowed; borrowing. Phrase borrowed time is from 1848.