Charge density wave (CDW) correlations have recently been shown to universally exist in cuprate superconductors. However, their nature at high fields inferred from nuclear magnetic resonance is distinct from that measured by x-ray scattering at zero and low fields. Here we combine a pulsed magnet with an x-ray free electron laser to characterize the CDW in YBa2Cu3O6.67 via x-ray scattering in fields up to 28 Tesla. While the zero-field CDW order, which develops below T ~ 150 K, is essentially two-dimensional, at lower temperature and beyond 15 Tesla, another three-dimensionally ordered CDW emerges. The field-induced CDW onsets around the zero-field superconducting transition temperature, yet the incommensurate in-plane ordering vector is field-independent. This implies that the two forms of CDW and high-temperature superconductivity are intimately linked.