SummaryPlant terpene synthase genes (TPSs) have roles in diverse biological processes. Here, we report the functional characterization of one member of the soybean TPS gene family, which was designated GmAFS. Recombinant GmAFS produced in Escherichia coli catalysed the formation of a sesquiterpene (E,E)‐α‐farnesene. GmAFS is closely related to (E,E)‐α‐farnesene synthase gene from apple, both phylogenetically and structurally. GmAFS was further investigated for its biological role in defence against nematodes and insects. Soybean cyst nematode (SCN) is the most important pathogen of soybean. The expression of GmAFS in a SCN‐resistant soybean was significantly induced by SCN infection compared with the control, whereas its expression in a SCN‐susceptible soybean was not changed by SCN infection. Transgenic hairy roots overexpressing GmAFS under the control of the CaMV 35S promoter were generated in an SCN‐susceptible soybean line. The transgenic lines showed significantly higher resistance to SCN, which indicates that GmAFS contributes to the resistance of soybean to SCN. In soybean leaves, the expression of GmAFS was found to be induced by Tetranychus urticae (two‐spotted spider mites). Exogenous application of methyl jasmonate to soybean plants also induced the expression of GmAFS in leaves. Using headspace collection combined with gas chromatography–mass spectrometry analysis, soybean plants that were infested with T. urticae were shown to emit a mixture of volatiles with (E,E)‐α‐farnesene as one of the most abundant constituents. In summary, this study showed that GmAFS has defence roles in both below‐ground and above‐ground organs of soybean against nematodes and insects, respectively.