A long-standing controversial issue in the quest to understand the superconductivity in cuprates is the nature of the enigmatic pseudogap region of the phase diagram(1). Especially important is whether the pseudogap state is a distinct thermodynamic phase characterized by broken symmetries below the onset temperature T*. Here we report torque-magnetometry measurements of anisotropic susceptibility within the ab planes in orthorhombic YBa2Cu3Oy with exceptionally high precision. The in-plane anisotropy displays a significant increase with a distinct kink at the pseudogap onset temperature T*, showing a remarkable scaling behaviour with respect to T/T* in a wide doping range. Our systematic analysis reveals that the rotational symmetry breaking sets in at T* in the limit where the effect of orthorhombicity is eliminated. These results provide thermodynamic evidence that the pseudogap onset is associated with a second-order nematic phase transition, which differs from the recently reported charge-density-wave transition that accompanies translational symmetry breaking(2-10).