Galactic cosmic rays (CRs) are widely believed to be accelerated by shock waves associated with the expansion of supernova ejecta into the interstellar medium. A key issue in this long-standing conjecture is a theoretical prediction that the interstellar magnetic field can be substantially amplified at the shock of a young supernova remnant (SNR) through magnetohydrodynamic waves generated by cosmic rays. Here we report a discovery of the brightening and decay of X-ray hot spots in the shell of the SNR RX J1713.7-3946 on a one-year timescale. This rapid variability shows that the X-rays are produced by ultrarelativistic electrons through a synchrotron process and that electron acceleration does indeed take place in a strongly magnetized environment, indicating amplification of the magnetic field by a factor of more than 100. The X-ray variability also implies that we have witnessed the ongoing shock-acceleration of electrons in real time. Independently, broadband X-ray spectrometric measurements of RX J1713.7-3946 indicate that electron acceleration proceeds in the most effective ('Bohm-diffusion') regime. Taken together, these two results provide a strong argument for acceleration of protons and nuclei to energies of 1 PeV (10(15) eV) and beyond in young supernova remnants.