When a two-dimensional (2D) electron gas is placed in a perpendicular magnetic field, its in-plane transverse conductance becomes quantized; this is known as the quantum Hall effect1. It arises from the non-trivial topology of the electronic band structure of the system, where an integer topological invariant (the first Chern number) leads to quantized Hall conductance. It has been shown theoretically that the quantum Hall effect can be generalized to four spatial dimensions2,3,4, but so far this has not been realized experimentally because experimental systems are limited to three spatial dimensions. Here we use tunable 2D arrays of photonic waveguides to realize a dynamically generated four-dimensional (4D) quantum Hall system experimentally. The inter-waveguide separation in the array is constructed in such a way that the propagation of light through the device samples over momenta in two additional synthetic dimensions, thus realizing a 2D topological pump5,6,7,8. As a result, the band structure has 4D topological invariants (known as second Chern numbers) that support a quantized bulk Hall response with 4D symmetry7. In a finite-sized system, the 4D topological bulk response is carried by localized edge modes that cross the sample when the synthetic momenta are modulated. We observe this crossing directly through photon pumping of our system from edge to edge and corner to corner. These crossings are equivalent to charge pumping across a 4D system from one three-dimensional hypersurface to the spatially opposite one and from one 2D hyperedge to another. Our results provide a platform for the study of higher-dimensional topological physics.