We derive a complete analytical solution for the powder magic angle spinning (MAS) nuclear magnetic resonance (NMR) lineshape in the presence of second-order quadrupole interaction, considering a radiofrequency (rf) pulse of finite width, a finite MAS frequency, and a non-zero asymmetry parameter. [I-x] is calculated using two approaches. The first applies time-dependent perturbation theory in the presence of the rf pulse and stationary perturbation theory (SPT) in its absence. The second is based on the Magnus expansion of the density matrix in the interaction representation during the pulse and SPT in its absence. We solve the problem in the laboratory frame using the properties of the Fourier transform and spin operators. Diagonalisation is not required. Both approaches agree well with each other under all conditions and also with the transition probability approach for the central transition. The Magnus expansion exists at all times and the effect of the non-secular terms is negligible. We describe an analytical method of averaging [I-x] over the Euler angles and simulate the B-11 MAS NMR lineshapes for crystalline and vitreous B2O3. A critical analysis is given of all earlier calculations of the MAS NMR lineshape. (C) 2000 Elsevier Science B.V. All rights reserved.