Spectral lines are the result of transitions between quantized energy levels of electrons in atoms or molecules, appearing as distinct lines at specific wavelengths in a spectrum. They serve as a unique fingerprint for identifying chemical elements and compounds, and are fundamental to the study of astrophysics and quantum mechanics.