A finite permutation group G on Ω is called a rank 3 group if it has precisely three orbits in its induced action on Ω × Ω. The largest permutation group on Ω having the same orbits as G on Ω × Ω is called the 2-closure of G. We construct a polynomial-time algorithm which given generators of a rank 3 group computes generators of its 2-closure.