We study the definability problem for first-order logic, denoted by FO-D ef . The input of FO-D ef is a relational database instance I and a relation R ; the question to answer is whether there exists a first-order query Q (or, equivalently, a relational algebra expression Q ) such that Q evaluated on I gives R as an answer. Although the study of FO-D ef dates back to 1978, when the decidability of this problem was shown, the exact complexity of FO-D ef remains as a fundamental open problem. In this article, we provide a polynomial-time algorithm for solving FO-D ef that uses calls to a graph-isomorphism subroutine (or oracle). As a consequence, the first-order definability problem is found to be complete for the class GI of all problems that are polynomial-time Turing reducible to the graph isomorphism problem, thus closing the open question about the exact complexity of this problem. The technique used is also applied to a generalized version of the problem that accepts a finite set of relation pairs, and whose exact complexity was also open; this version is also found to be GI -complete.