The relation between the on-shell quark mass and the mass defined in the modified minimal subtraction scheme is computed up to order \alpha_s^3. Implications for the numerical values of the top and bottom quark masses are discussed. We show that the new three-loop correction significantly reduces the theoretical uncertainty in the determination of the quark masses.