Mass spectrometry is an instrumental technique that analyzes samples by converting molecules to ions and separating them based on their mass-to-charge ratios. It works by first ionizing a sample through electron bombardment, then accelerating the ions and passing them through electric and magnetic fields to deflect them into a detector based on their masses. The detector then records the number of ions at each mass, allowing the user to determine the composition of the original sample.