Long duration gamma-ray bursts (GRBs), the brightest events since the Big Bang itself, are believed to originate in an ultra-relativistic jet breaking out from a massive stellar envelope. Despite decades of study, there is still no consensus on their emission mechanism. One unresolved question is the origin of the tight correlation between the spectral peak energy Ep and peak luminosity Lp discovered in observations. This Yonetoku relation is the tightest correlation found in the properties of the prompt phase of GRB emission, providing the best diagnostic for the radiation mechanism. Here we present 3D hydrodynamical simulations, and post-process radiation transfer calculations, of photospheric emission from a relativistic jet. Our simulations reproduce the Yonetoku relation as a natural consequence of viewing angle. Although jet dynamics depend sensitively on luminosity, the Ep-Lp correlation holds regardless. This result strongly suggests that photospheric emission is the dominant component in the prompt phase of GRBs.