In the quest to increase the critical temperature Tc of cuprate superconductors, it is essential to identify the factors that limit the strength of superconductivity. The upper critical field Hc2 is a fundamental measure of that strength, yet there is no agreement on its magnitude and doping dependence in cuprate superconductors. Here we show that the thermal conductivity can be used to directly detect Hc2 in the cuprates YBa2Cu3Oy, YBa2Cu4O8 and Tl2Ba2CuO6+δ, allowing us to map out Hc2 across the doping phase diagram. It exhibits two peaks, each located at a critical point where the Fermi surface of YBa2Cu3Oy is known to undergo a transformation. Below the higher critical point, the condensation energy, obtained directly from Hc2, suffers a sudden 20-fold collapse. This reveals that phase competition-associated with Fermi-surface reconstruction and charge-density-wave order-is a key limiting factor in the superconductivity of cuprates.