Purpose: MRI-linac therapy is a rapidly growing field, and requires that conventional linear accelerators are operated with the fringe field of MRI magnets. One of the most sensitive accelerator components is the electron gun, which serves as the source of the beam. The purpose of this work was to develop a validated finite element model (FEM) model of a clinical triode (or gridded) electron gun, based on accurate geometric and electrical measurements, and to characterize the performance of this gun in magnetic fields. Methods: The geometry of a Varian electron gun was measured using 3D laser scanning and digital calipers. The electric potentials and emission current of these guns were measured directly from six dose matched true beam linacs for the 6X, 10X, and 15X modes of operation. Based on these measurements, a finite element model (FEM) of the gun was developed using the commercial software /. The performance of the FEM model in magnetic fields was characterized using parallel fields ranging from 0 to 200 G in the in-line direction, and 0-35 G in the perpendicular direction.Results: The FEM model matched the average measured emission current to within 5% across all three modes of operation. Different high voltage settings are used for the different modes; the 6X, 10X, and 15X modes have an average high voltage setting of 15, 10, and 11 kV. Due to these differences, different operating modes show different sensitivities in magnetic fields. For in line fields, the first current loss occurs at 40, 20, and 30 G for each mode. This is a much greater sensitivity than has previously been observed. For perpendicular fields, first beam loss occurred at 8, 5, and 5 G and total beam loss at 27, 22, and 20 G. Conclusions: A validated FEM model of a clinical triode electron gun has been developed based on accurate geometric and electrical measurements. Three different operating modes were simulated, with a maximum mean error of 5%. This gun shows greater sensitivity to in-line magnetic fields than previously presented models, and different operating modes show different sensitivity. C 2016 American Association of Physicists in Medicine. [http://dx