We present a determination of the b-quark mass accurate through O(alpha_s^2) in perturbation theory and including partial contributions at O(alpha_s^3). Nonperturbative input comes from the calculation of the Upsilon and B_s energies in lattice QCD including the effect of u, d and s sea quarks. We use an improved NRQCD action for the b-quark. This is combined with the heavy quark energy shift in NRQCD determined using a mixed approach of high-beta simulation and automated lattice perturbation theory. Comparison with experiment enables the quark mass to be extracted: in the MS bar scheme we find m_b(m_b) = 4.166(43) GeV.