A combined experimental (superconductor-insulator-superconductor tunneling spectra) and theoretical (density functional theory) study of the two-gap superconductor MgB2 is reported. The calculations confirm that the small gap is associated with a π band mostly based on the boron pz orbitals leading to the three-dimensional band component of the Fermi surface. This channel almost completely dominates the tunneling images and spectra for c-axis-oriented samples and not the two-dimensional σband. The origin of this effect is due to the faster decay of the electronic states associated with the boron px and py orbitals compared to those associated with the boron pz orbitals, together with the symmetry properties of the wave functions. The calculated tunneling channels and partial density of states for each band agree with the values deduced from precise fits of experimental tunneling spectra. The present approach provides a framework for the understanding of tunneling spectra and the nature of superconducting gaps of other multigap superconductors.