This paper presents a measurement of the double-differential cross section for the Drell-Yan Z/γ∗ → ℓ+ℓ− and photon-induced γγ → ℓ+ℓ− processes where ℓ is an electron or muon. The measurement is performed for invariant masses of the lepton pairs, mℓℓ, between 116 GeV and 1500 GeV using a sample of 20.3 fb−1 of pp collisions data at centre-of-mass energy of s√=8s=8 TeV collected by the ATLAS detector at the LHC in 2012. The data are presented double differentially in invariant mass and absolute dilepton rapidity as well as in invariant mass and absolute pseudorapidity separation of the lepton pair. The single-differential cross section as a function of mℓℓ is also reported. The electron and muon channel measurements are combined and a total experimental precision of better than 1% is achieved at low mℓℓ. A comparison to next-to-next-to-leading order perturbative QCD predictions using several recent parton distribution functions and including next-to-leading order electroweak effects indicates the potential of the data to constrain parton distribution functions. In particular, a large impact of the data on the photon PDF is demonstrated.