We demonstrate the feasibility of ab initio studies of piezoelectricity within an all-electron scheme. The focus of our analysis is on wurtzite ZnO; for comparison, some results are also presented for the related materials BeO and ZnS. The comparative study is performed in order to understand the microscopic origin of the peculiar behavior of ZnO, whose piezoelectric response is the strongest among the tetrahedrally bonded semiconductors. In all such materials, the piezeoelectric effect results from two different terms of opposite sign: these are usually referred to as the ``clamped-ion'' and the ``internal-strain'' contributions. Cancellation among them is least effective in ZnO, where the dominant effect is due to a rigid-ion-like mechanism. Furthermore, we compute the spontaneous polarization of ZnO and we discuss the puzzling agreement between our calculated value and a very indirect experimental estimate of the same quantity.