Two-dimensional electronic states at surfaces are often observed in simple wide-band metals such as Cu or Ag (refs. 1–4). Confinement by closed geometries at the nanometre scale, such as surface terraces, leads to quantized energy levels formed from the surface band, in stark contrast to the continuous energy dependence of bulk electron bands2,5–10. Their energy-level separation is typically hundreds of meV (refs. 3,6,11). In a distinct class of materials, strong electronic correlations lead to so-called heavy fermions with a strongly reduced bandwidth and exotic bulk ground states12,13. Quantum-well states in two-dimensional heavy fermions (2DHFs) remain, however, notoriously difficult to observe because of their tiny energy separation. Here we use millikelvin scanning tunnelling microscopy (STM) to study atomically flat terraces on U-terminated surfaces of the heavy-fermion superconductor URu2Si2, which exhibits a mysterious hidden-order (HO) state below 17.5 K (ref. 14). We observe 2DHFs made of 5f electrons with an effective mass 17 times the free electron mass. The 2DHFs form quantized states separated by a fraction of a meV and their level width is set by the interaction with correlated bulk states. Edge states on steps between terraces appear along one of the two in-plane directions, suggesting electronic symmetry breaking at the surface. Our results propose a new route to realize quantum-well states in strongly correlated quantum materials and to explore how these connect to the electronic environment.