Mass spectrometry is an analytical technique that measures the mass-to-charge ratio of ions to identify and quantify the chemical composition of a sample. It provides detailed information about the molecular structure and fragmentation patterns of compounds, making it a powerful tool in organic chemistry and various other fields.