Piezoelectric materials, which convert mechanical to electrical energy (and vice versa), are crucial in medical imaging, telecommunication and ultrasonic devices. A new generation of single-crystal materials, such as Pb(Zn1/3Nb2/3)O3-PbTiO3 (PZN-PT) and Pb(Mg1/3Nb2/3)O3-PbTiO3 (PMN-PT), exhibit a piezoelectric effect that is ten times larger than conventional ceramics, and may revolutionize these applications. However, the mechanism underlying the ultrahigh performance of these new materials-and consequently the possibilities for further improvements-are not at present clear. Here we report a first-principles study of the ferroelectric perovskite, BaTiO3, which is similar to single-crystal PZN-PT but is a simpler system to analyse. We show that a large piezoelectric response can be driven by polarization rotation induced by an external electric field. Our computations suggest how to design materials with better performance, and may stimulate further interest in the fundamental theory of dielectric systems in finite electric fields.