We present a calculation of the hadronic vacuum polarization contribution to the muon anomalous magnetic moment, a hvp μ , in lattice QCD employing dynamical up and down quarks. We focus on controlling the infrared regime of the vacuum polarization function. To this end we employ several complementary approaches, including Padé fits, time moments and the time-momentum representation. We correct our results for finite-volume effects by combining the Gounaris-Sakurai parameterization of the timelike pion form factor with the Lüscher formalism. On a subset of our ensembles we have derived an upper bound on the magnitude of quark-disconnected diagrams and found that they decrease the estimate for a hvp μ by at most 2%. Our final result is ahvpμ=(654±32+21−23)·10−10, where the first error is statistical, and the second denotes the combined systematic uncertainty. Based on our findings we discuss the prospects for determining a hvp μ with sub-percent precision.