The recent discovery that a spin-polarized electrical current can apply a large torque to a ferromagnet, through direct transfer of spin angular momentum, offers the possibility of manipulating magnetic-device elements without applying cumbersome magnetic fields. However, a central question remains unresolved: what type of magnetic motions can be generated by this torque? Theory predicts that spin transfer may be able to drive a nanomagnet into types of oscillatory magnetic modes not attainable with magnetic fields alone, but existing measurement techniques have provided only indirect evidence for dynamical states. The nature of the possible motions has not been determined. Here we demonstrate a technique that allows direct electrical measurements of microwave-frequency dynamics in individual nanomagnets, propelled by a d.c. spin-polarized current. We show that spin transfer can produce several different types of magnetic excitation. Although there is no mechanical motion, a simple magnetic-multilayer structure acts like a nanoscale motor; it converts energy from a d.c. electrical current into high-frequency magnetic rotations that might be applied in new devices including microwave sources and resonators.