A mass spectrometer includes a main magnet having spaced-apart polepieces which define a gap, the main magnet producing a magnetic field in the gap, an ion source to generate ions and to accelerate the ions into the magnetic field in the gap, the ion source located outside the gap, and an ion detector to detect a selected species of the ions generated by the ion source and deflected by the magnetic field. The ion detector is located in the gap at a natural focus point of the selected species of ions. The mass spectrometer may be used in a trace gas leak detector.