Two-dimensional particle-in-cell simulations were performed to demonstrate the fluctuation of the maximum beam energy while varying the plasma density in a laser wakefield accelerator (LWFA) under the transition from mildly relativistic regime to relativistic regime. The fluctuation of the beam energy is induced by the unstable accelerating structure, which length is dynamically oscillating between the plasma wavelength and the relativistic plasma wavelength. The simulation results also reveal the existence of the parameter space for the stable operation of a LWFA. An empirical formulation was derived by the curve fitting of the simulated radius of curvature of the returning electrons along the boundary of the plasma bubble in a stably operated LWFA. The comparisons between the energy scaling law derived from the empirical formulation, the two-dimensional and three-dimensional PIC simulations, and previous experimental results with self-guided laser pulses show good agreement. The scaling law derived in the study can provide a correct estimation of the maximum beam energy for a newly designed LWFA experiment with an optimal configuration of the laser pulse. (C) 2010 American Institute of Physics. [doi :10.1063/1.3447872]