The world-class Gejiu Sn-polymetallic district (southwest China), with ca. 3.27 Mt Sn metal, is a magmatic-hydrothermal deposit associated with the Late Cretaceous biotite granites; however, the magmatic and hydrothermal processes involved in its formation remain poorly understood. Tourmaline is a ubiquitous phase in the Gejiu district, and here we employ in-situ major, trace element, and boron isotope compositions of tourmaline to investigate the source and evolution of the mineralizing fluid, and late-magmatic and hydrothermal processes related to ore formation. Based on petrographic observations, four types of tourmaline are identified: i) late-magmatic tourmaline (Tur I) disseminated in the biotite granites, ii) hydrothermal tourmaline (Tur II) from quartz veins with fracture-filling structure in the biotite granites, iii) hydrothermal tourmaline (Tur IIIa-1, IIIa-2 and Tur IIIb-1, IIIb-2) from fluorite-quartz veins with typical replacement texture against the greisenized granites, among which Tur IIIb-2 is directly related to cassiterite formation, and iv) hydrothermal tourmaline (Tur IV) from sulfide-calcite veins hosted by proximal skarn. Tourmaline (Tur I to Tur III) from the granites belongs mostly to the alkali group and schorl-dravite solid-solution series, with Fe/(Fe + Mg) ranging from 0.83–1.00 for Tur I, 0.68–1.00 for Tur II, and 0.19–1.00 for Tur III, respectively. By contrast, Tur IV belongs mostly to the vacancy group and has foitite–Mg-foitite composition, with Fe/(Fe + Mg) of 0.10–1.00. Large variations of Fe/(Fe + Mg) as well as Na/(Na + Ca) in hydrothermal tourmaline (Tur II to Tur IV), are related to different degrees of interaction between B-rich fluids with host rocks (solidified granite or carbonate). Most trace elements in tourmaline do not correlate with Fe/(Fe + Mg) and Na/(Na + Ca) ratios, implying the trace element compositions are predominantly controlled by melt/fluid compositions and local fluid-rock reactions. Relative to late-magmatic Tur I, hydrothermal tourmaline (Tur II to Tur IV) is enriched in Sr and depleted in Nb, Ta, and (REE + Y), whereas their Li, Be, Sc, V, and Sn concentrations are largely overlapped. The δ11B values in different types of tourmaline fall in a narrow range from −17.8 to −13.7‰, in favor of B-rich fluids episodically exsolved from the granitic melt.Tin enrichment in both late-magmatic and hydrothermal tourmaline grains, especially in those (Tur IIIb) from Sn-mineralized veins, is related to magmatic differentiation and late-stage fluid exsolution. Among all types of tourmaline, Tur IIIb-2 coexisting with cassiterite has elevated Fe3+/(Fe3+ + Fe2+) ratios (mean 0.23), indicating that cassiterite precipitated under relatively oxidized conditions. The distinct chemical (i.e. high Mg, Ti, V, Sc, Sr, and Sn contents) and B-isotope compositions (slightly lower δ11B values of −17.8 to −15.0‰) in syn-ore Tur IIIb-2, combined with the co-occurrence of liquid- and vapor-rich inclusions triggered by fluid boiling in Sn-mineralized veins, suggest that fluid boiling and acid-consuming reaction could be major processes triggering cassiterite precipitation in the quartz vein and greisen. Overall, the chemical and B-isotope signatures of tourmaline are ideal tracers to unravel the magmatic-hydrothermal evolution in the Gejiu Sn-polymetallic district, which could be further employed as a potential prospecting guide for SnW deposits.