In this paper, we establish the existence of periodic orbits of a twisted geodesic flow on all low energy levels and in all dimensions whenever the magnetic field form is symplectic and spherically rational. This is a consequence of a more general theorem concerning periodic orbits of autonomous Hamiltonian flows near Morse–Bott non-degenerate, symplectic extrema. Namely, we show that all energy levels near such extrema carry periodic orbits, provided that the ambient manifold meets certain topological requirements. This result is a partial generalization of the Weinstein–Moser theorem. The proof of the generalized Weinstein–Moser theorem is a combination of a Sturm-theoretic argument and a Floer homology calculation.