The nature of dark matter remains mysterious, with luminous material accounting for at most similar to 25 per cent of the baryons in the Universe(1,2). We accordingly undertook a survey looking for the microlensing of stars in the Large Magellanic Cloud (LMC) to determine the fraction of Galactic dark matter contained in massive compact halo objects (MACHOs). The presence of the dark matter would be revealed by gravitational lensing of the light from an LMC star as the foreground dark matter moves across the line of sight. The duration of the lensing event is the key observable parameter, but gives non-unique solutions when attempting to estimate the mass, distance and transverse velocity of the lens. The survey results to date indicate that between 8 and 50 per cent of the baryonic mass of the Galactic halo is in the form of MACHOs (ref. 3), but removing the degeneracy by identifying a lensing object would tighten the constraints on the mass in MACHOs. Here we report a direct image of a microlens, revealing it to be a nearby low-mass star in the disk of the Milky Way. This is consistent with the expected frequency of nearby stars acting as lenses, and demonstrates a direct determination of a lens mass from a microlensing event. Complete solutions such as this for halo microlensing events will probe directly the nature of the MACHOs.