The tumour microenvironment, also termed the tumour stroma or tumour mesenchyme, includes fibroblasts, immune cells, blood vessels and the extracellular matrix and substantially influences the initiation, growth and dissemination of gastrointestinal cancer. Cancer-associated fibroblasts (CAFs) are one of the critical components of the tumour mesenchyme and not only provide physical support for epithelial cells but also are key functional regulators in cancer, promoting and retarding tumorigenesis in a context-dependent manner. In this Review, we outline the emerging understanding of gastrointestinal CAFs with a particular emphasis on their origin and heterogeneity, as well as their function in cancer cell proliferation, tumour immunity, angiogenesis, extracellular matrix remodelling and drug resistance. Moreover, we discuss the clinical implications of CAFs as biomarkers and potential targets for prevention and treatment of patients with gastrointestinal cancer.