Quantum simulation has emerged as a valuable arena for demonstrating and understanding the capabilities of near-term quantum computers1,2,3. Quantum annealing4,5 has been successfully used in simulating a range of open quantum systems, both at equilibrium6,7,8 and out of equilibrium9,10,11. However, in all previous experiments, annealing has been too slow to coherently simulate a closed quantum system, due to the onset of thermal effects from the environment. Here we demonstrate coherent evolution through a quantum phase transition in the paradigmatic setting of a one-dimensional transverse-field Ising chain, using up to 2,000 superconducting flux qubits in a programmable quantum annealer. In large systems, we observe the quantum Kibble–Zurek mechanism with theoretically predicted kink statistics, as well as characteristic positive kink–kink correlations, independent of temperature. In small chains, excitation statistics validate the picture of a Landau–Zener transition at a minimum gap. In both cases, the results are in quantitative agreement with analytical solutions to the closed-system quantum model. For slower anneals, we observe anti-Kibble–Zurek scaling in a crossover to the open quantum regime. The coherent dynamics of large-scale quantum annealers demonstrated here can be exploited to perform approximate quantum optimization, machine learning and simulation tasks.