We present a study of the polarization of the Upsilon(1S) and Upsilon(2S) states using a 1.3 fb;{-1} data sample collected by the D0 experiment in 2002-2006 during run II of the Fermilab Tevatron Collider. We measure the polarization parameter alpha=(sigma_{T}-2sigma_{L})/(sigma_{T}+2sigma_{L}), where sigma_{T} and sigma_{L} are the transversely and longitudinally polarized components of the production cross section, as a function of the transverse momentum (p_{T};{Upsilon}) for the Upsilon(1S) and Upsilon(2S). Significant p_{T};{Upsilon}-dependent longitudinal polarization is observed for the Upsilon(1S). A comparison with theoretical models is presented.