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 $bf sim 3.2$ lattice units in the copper-oxide planes of the superconductors (Y,Nd)Ba$_2$Cu$_3$O$_{6+x}$ with hole concentrations $0.09 leq p leq 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, $T_c$; further cooling below $T_c$ 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.