The ideal magnetohydrodynamic (MHD) stability of the National Compact Stellarator Experiment (NCSX) is extensively analyzed using the most advanced three-dimensional MHD codes. It is shown that the NCSX is stable to finite-n MHD modes, including the vertical mode, external kink modes and ballooning modes. However, high-n external kink modes that peak near the plasma edge are found to be weakly unstable. A global calculation shows that finite-n ballooning modes are significantly more stable than the local infinite-n modes.