We report first-principles calculations of the structural, lattice-dynamical, and dielectric properties for zincblende and wurtzite BN and AlN. The ground-state properties, i.e., the lattice constants, the bulk moduli, the ionicity factors of the chemical bonds, and the elastic constants, are calculated using a plane-wavepseudopotential method within the density-functional theory. A linear-response approach to the densityfunctional theory is used to derive the Born effective charges, the high-frequency dielectric constants, and the phonon frequencies and eigenvectors. The different behavior of the structural and lattice-dynamical properties of BN and AlN is discussed in terms of the different ionicities, strengths of the covalent bonds, and the atomic masses. Our results are in excellent agreement with the experimental data available.