We extend the two-dimensional two-layer outer gap model to a three-dimensional geometry and use it to study the high-energy emission of the Vela pulsar. In this model, the outer gap is divided into two parts, i.e. the main acceleration region on the top of last-open field lines and the screening region around the upper boundary of the gap. In the main acceleration region, the charge density is much lower than the Goldreich–Julian charge density, and the charged particles are accelerated by the electric field along the magnetic field to emit multi-GeV photons. In the screening region, the charge density is larger than the Goldreich–Julian value to close the gap, and particles in this region are responsible for multi-100 MeV photon emission. We apply this three-dimensional two-layer model to the Vela pulsar and compare the model light curves, the phase-averaged spectrum and the phase-resolved spectra with the recent Fermi observations, which also reveals the existence of the third peak between two main peaks. The phase position of the third peak moves with the photon energy, which cannot be explained by the geometry of magnetic field structure and the caustic effects of the photon propagation. We suggest that the existence of the third peak and its energy-dependent movement results from the azimuthal structure of the outer gap.