There are increasing indications that superconductivity competes with other orders in cuprate superconductors, but obtaining direct evidence with bulk-sensitive probes is challenging. We have used resonant soft x-ray scattering to identify two-dimensional charge fluctuations with an incommensurate periodicity of ∼3.2 lattice units in the copper-oxide planes of the superconductors (Y,Nd)Ba2Cu3O6+x with hole concentrations 0.09≤p≤0.13 per planar Cu ion. The intensity and correlation length of the fluctuation signal increase strongly upon cooling down to the superconducting transition temperature, Tc; further cooling below Tc abruptly reverses the divergence of the charge correlations. In combination with prior observations of a large gap in the spin excitation spectrum, these data indicate an incipient charge-density-wave instability that competes with superconductivity.