There is currently much interest in the development of 'spintronic' devices, in which harnessing the spins of electrons (rather than just their charges) is anticipated to provide new functionalities that go beyond those possible with conventional electronic devices. One widely studied example of an effect that has its roots in the electron's spin degree of freedom is the torque exerted by a spin-polarized electric current on the spin moment of a nanometre-scale magnet. This torque causes the magnetic moment to rotate at potentially useful frequencies. Here we report a very different phenomenon that is also based on the interplay between spin dynamics and spin-dependent transport, and which arises from unusual diode behaviour. We show that the application of a small radio-frequency alternating current to a nanometre-scale magnetic tunnel junction can generate a measurable direct-current (d.c.) voltage across the device when the frequency is resonant with the spin oscillations that arise from the spin-torque effect: at resonance (which can be tuned by an external magnetic field), the structure exhibits different resistance states depending on the direction of the current. This behaviour is markedly different from that of a conventional semiconductor diode, and could form the basis of a nanometre-scale radio-frequency detector in telecommunication circuits.