The stability of the tokamak edge pedestal to ballooning modes is addressed using three-dimensional simulations of the Braginskii equations and simple analytic models. The effects of ion diamagnetic drift and the finite radial localization of the pedestal pressure gradient are found to be strongly stabilizing when delta <delta(R), where delta is the pedestal half-width and delta(R)similar to rho(i)(2/3)R(1/3) in the center of the pedestal. In this limit, conventional ballooning modes within the pedestal region become stable, and a stability condition is obtained in the two fluid system alpha/alpha(c)<(4/3)delta(R)/delta (stable) which is much less stringent than that predicted by local magnetohydrodynamic (MHD) theory (alpha/alpha(c)< 1). Given alpha similar to q(2)R beta/delta, this condition implies a stability limit on the pedestal beta: beta <beta(c), where beta(c)=(4 alpha(c)/3q(2))delta(R)/R. This limit is due the onset of an ideal pressure driven "surface" instability that depends only on the pressure drop across the pedestal. Near marginal conditions, this mode has a poloidal wavenumber k(theta)similar to 1/delta(R), a radial envelope similar to delta(R)(>delta), and real frequency omega similar to c(s)/root delta(R)R. (C) 1999 American Institute of Physics. [S1070-664X(99)03007-4].