Linear vector waves, both quantum and classical, experience polarization-driven bending of ray trajectories and polarization dynamics that can be interpreted as the precession of the "wave spin". Both phenomena are governed by an effective gauge Hamiltonian, which vanishes in leading-order geometrical optics. This gauge Hamiltonian can be recognized as a generalization of the SternGerlach Hamiltonian that is commonly known for spin-1/2 quantum particles. The corresponding reduced Lagrangians for continuous nondissipative waves and their geometrical-optics rays are derived from the fundamental wave Lagrangian. The resulting Euler-Lagrange equations can describe simultaneous interactions of N resonant modes, where N is arbitrary, and lead to equations for the wave spin, which happens to be a (N 2 −1)-dimensional spin vector. As a special case, classical equations for a Dirac particle (N = 2) are deduced formally, without introducing additional postulates or interpretations, from the Dirac quantum Lagrangian with the Pauli term. The model reproduces the Bargmann-Michel-Telegdi equations with added Stern-Gerlach force.