Transport barrier formation and its relation to sheared flows in fluids and plasmas are of fundamental interest in various natural and laboratory observations and of critical importance in achieving an economical energy production in a magnetic fusion device. Here we report the first observation of an edge transport barrier formation event in a gyrokinetic simulation carried out in a realistic tokamak edge geometry. The results show that turbulent Reynolds stress driven sheared ExB flows act in concert with neoclassical orbit loss to quench turbulent transport and form a transport barrier just inside the last closed magnetic flux surface.