For the 40 K superconductor MgB2, we have calculated the electronic and phononic structures and the electron-phonon (e-ph) interaction throughout the Brillouin zone ab initio. In contrast to the isoelectronic graphite, MgB2 has holes in the bonding sigma bands, which contribute 42% to the density of states: N(0) = 0.355 states/(MgB2)(eV) (spin). The total interaction strength, lambda = 0.87 and lambda (tr) = 0.60, is dominated by the coupling of the sigma holes to the bond-stretching optical phonons with wave numbers in a narrow range around 590 cm(-1). Like the holes, these phonons are quasi-two-dimensional and have wave vectors close to GammaA, where their symmetry is E. The pi electrons contribute merely 0.25 to lambda and to lambda (tr). With Eliashberg theory we evaluate the normal-state resistivity, the density of states in the superconductor, and the B-isotope effect on T-c and Delta (0), and find excellent agreement with experiments, when available. T-c = 40 K is reproduced with mu* = 0.10 and 2 Delta (0)/k(B)T(c) = 3.9. MgB2 thus seems to be an intermediate-coupling e-ph pairing s-wave superconductor.