Context. Only a few stars are caught in the very brief and often crucial stages when they quickly traverse the Hertzsprung-Russell diagram, and none has yet been spatially resolved in the mass transfer phase. Aims. We initiated long-term optical interferometry monitoring of the diameters of massive and unstable yellow hypergiants (YHG) with the goal of detecting both the long-term evolution of their radius and shorter term formation of a possible pseudo-photosphere related to proposed large mass-loss events. Methods. We observed HR 5171 A with AMBER/VLTI. We also examined archival photometric data in the visual and near-IR spanning more than 60 years, as well as sparse spectroscopic data. Results. HR 5171 A exhibits a complex appearance. Our AMBER data reveal a surprisingly large star for a YHG R * = 1315 ± 260 R (or ∼6.1 AU) at the distance of 3.6 ± 0.5 kpc. The source is surrounded by an extended nebulosity, and these data also show a large level of asymmetry in the brightness distribution of the system, which we attribute to a newly discovered companion star located in front of the primary star. The companion's signature is also detected in the visual photometry, which indicates an orbital period of P orb = 1304 ± 6 d. Modeling the light curve with the NIGHTFALL program provides clear evidence that the system is a contact or possibly over-contact eclipsing binary. A total current system mass of 39 +40 −22 M and a high mass ratio q ≥ 10 is inferred for the system. Conclusions. The low-mass companion of HR 5171 A is very close to the primary star that is embedded within its dense wind. Tight constraints on the inclination and v sin i of the primary are lacking, which prevents us from determining its influence precisely on the mass-loss phenomenon, but the system is probably experiencing a wind Roche-Lobe overflow. Depending on the amount of angular momentum that can be transferred to the stellar envelope, HR 5171 A may become a fast-rotating B[e]/luminous blue variable/Wolf-Rayet star. In any case, HR 5171 A highlights the possible importance of binaries for interpreting the unstable YHGs and for massive star evolution in general.