In 1959 Buchdahl [H.A. Buchdahl, General relativistic fluid spheres, Phys. Rev. 116 (1959) 1027-1034] obtained the inequality 2M/R <= 8/9 under the assumptions that the energy density is non-increasing outwards and that the pressure is isotropic. Here M is the ADM mass and R the area radius of the boundary of the static body. The assumptions used to derive the Buchdahl inequality are very restrictive and for instance neither of them hold in a simple soap bubble. In this work we remove both of these assumptions and consider any static solution of the spherically symmetric Einstein equations for which the energy density rho >= 0, and the radial and tangential pressures p >= 0 and p(T) satisfy p + 2(PT) <= Omega rho, Omega > 0, and we show that sup(r>0) 2m(r)/r <= (1 + 2 Omega)(2) - 1/(1 + 2 Omega)(2) where m is the quasi-local mass, so that in particular M = m(R). We also show that the inequality is sharp under these assumptions. Note that when Omega = 1 the original bound by Buchdahl is recovered. The assumptions on the matter model are very general and in particular any model with p >= 0 which satisfies the dominant energy condition satisfies the hypotheses with Omega = 3. (C) 2008 Elsevier Inc. All rights reserved.