We consider a reversal of the magnetic moment of a nanomagnet by a fluctuating spin torque induced by a nonequilibrium current of electron spins. This is an example of the problem of the escape of a particle from a metastable state subjected to a fluctuating nonconservative force. Spin torque is a nonconservative force, and its fluctuations are beyond the description of the fluctuation-dissipation theorem. We estimate the joint probability distribution of work done by the spin torque and the Joule heat generated by the current, which satisfies the fluctuation theorem for a small engine. We predict a threshold voltage above which the spin-torque shot noise induces probabilistic switching events and below which such events are blocked. We adopt the theory of full-counting statistics under the adiabatic pumping of spin angular momentum. This enables us to account for the backaction effect, which is crucial to maintain consistency with the fluctuation theorem.