Anisotropy is one factor that appears to be significantly important in the studies of relativistic compact stars. In this paper, we make a generalization of the Buchdahl limit by incorporating an anisotropic effect for a selected class of exact solutions describing anisotropic stellar objects. In the isotropic case of a homogeneous distribution, we regain the Buchdahl limit $2M/R leq 8/9$. Our investigation shows a direct link between the maximum allowed compactness and pressure anisotropy vi-a-vis geometry of the associated $3$-space.