The magnetic moment of a single-domain nanoparticle can be effectively switched on an ultrashort time scale by means of oscillating (microwave) magnetic fields. This switching technique can be further improved by using fields with time-dependent frequency (autoresonance). Here, we provide a full theoretical framework for the autoresonant switching technique, by exploiting the analogy between the magnetization state of an isolated nanoparticle and a two-level quantum system, whereby the switching process can be interpreted as a population transfer. We derive analytical expressions for the threshold amplitude of the microwave field, with and without damping, and consider the effect of thermal fluctuations. Comparisons with numerical simulations show excellent agreement.