Electronic nematic materials are characterized by a lowered symmetry of the electronic system compared to the underlying lattice, in analogy to the directional alignment without translational order in nematic liquid crystals. Such nematic phases appear in the copper- and iron-based high-temperature superconductors, and their role in establishing superconductivity remains an open question. Nematicity may take an active part, cooperating or competing with superconductivity, or may appear accidentally in such systems. Here we present experimental evidence for a phase of fluctuating nematic character in a heavy-fermion superconductor, CeRhIn5 (ref. 5). We observe a magnetic-field-induced state in the vicinity of a field-tuned antiferromagnetic quantum critical point at Hc ≈ 50 tesla. This phase appears above an out-of-plane critical field H* ≈ 28 tesla and is characterized by a substantial in-plane resistivity anisotropy in the presence of a small in-plane field component. The in-plane symmetry breaking has little apparent connection to the underlying lattice, as evidenced by the small magnitude of the magnetostriction anomaly at H*. Furthermore, no anomalies appear in the magnetic torque, suggesting the absence of metamagnetism in this field range. The appearance of nematic behaviour in a prototypical heavy-fermion superconductor highlights the interrelation of nematicity and unconventional superconductivity, suggesting nematicity to be common among correlated materials.