early 15c., "a composition, a chronicle, the entire text of a writing," from Latin contextus "a joining together," originally past participle of contexere "to weave together," from assimilated form of com "with, together" (see con-) + texere "to weave, to make" (from PIE root *teks- "to weave," also "to fabricate").

Meaning "the parts of a writing or discourse which precede or follow, and are directly connected with, some other part referred to or quoted" is from 1560s.