In this article, we prove that if a finitely presented group has an asymptotic cone which is tree-graded with respect to a precise set of pieces then it is relatively hyperbolic. This answers a question of M. Sapir.