  We present a first principles investigation of the lattice dynamics and
electron-phonon coupling of the superconductor MgB_2 and the isostructural
AlB_2 within the framework of density functional perturbation theory using a
mixed-basis pseudopotential method. Complete phonon dispersion curves and
Eliashberg functions \alpha^2F are calculated for both systems. We also report
on Raman measurements, which support the theoretical findings. The calculated
generalized density-of-states for MgB_2 is in excellent agreement with recent
neutron-scattering experiments. The main differences in the calculated phonon
spectra and \alpha^2F are related to high frequency in-plane boron vibrations.
As compared to AlB_2, they are strongly softened in MgB_2 and exhibit an
exceptionally strong coupling to electronic states at the Fermi energy. The
total coupling constants are \lambda_{MgB_2}=0.73 and \lambda_{AlB_2}=0.43.
Implications for the superconducting transition temperature are briefly
discussed.
