This paper develops the geometry and analysis of the averaged Euler equations for ideal incompressible flow in domains in Euclidean space and on Riemannian manifolds, possibly with boundary. The averaged Euler equations involve a parameter $alpha$; one interpretation is that they are obtained by ensemble averaging the Euler equations in Lagrangian representation over rapid fluctuations whose amplitudes are of order $alpha$. The particle flows associated with these equations are shown to be geodesics on a suitable group of volume preserving diffeomorphisms, just as with the Euler equations themselves (according to Arnolds theorem), but with respect to a right invariant $H^1$ metric instead of the $L^2$ metric. The equations are also equivalent to those for a certain second grade fluid. Additional properties of the Euler equations, such as smoothness of the geodesic spray (the Ebin-Marsden theorem) are also shown to hold. Using this nonlinear analysis framework, the limit of zero viscosity for the corresponding viscous equations is shown to be a regular limit, {it even in the presence of boundaries}.