This is the first treatment entirely dedicated to an analytic study of spectral flow for paths of selfadjoint Fredholm operators, possibly unbounded or understood in a semifinite sense. The importance of spectral flow for homotopy and index theory is discussed in detail. Applications concern eta-invariants, the Bott-Maslov and Conley-Zehnder indices, Sturm-Liouville oscillation theory, the spectral localizer and bifurcation theory.