The Hall coefficient R_H of the cuprate superconductor YBa2Cu3Oy was measured in magnetic fields up to 60 T for a hole concentration p from 0.078 to 0.152, in the underdoped regime. In fields large enough to suppress superconductivity, R_H(T) is seen to go from positive at high temperature to negative at low temperature, for p > 0.08. This change of sign is attributed to the emergence of an electron pocket in the Fermi surface at low temperature. At p < 0.08, the normal-state R_H(T) remains positive at all temperatures, increasing monotonically as T to 0. We attribute the change of behaviour across p = 0.08 to a Lifshitz transition, namely a change in Fermi-surface topology occurring at a critical concentration p_L = 0.08, where the electron pocket vanishes. The loss of the high-mobility electron pocket across p_L coincides with a ten-fold drop in the conductivity at low temperature, revealed in measurements of the electrical resistivity $rho$ at high fields, showing that the so-called metal-insulator crossover of cuprates is in fact driven by a Lifshitz transition. It also coincides with a jump in the in-plane anisotropy of $rho$, showing that without its electron pocket the Fermi surface must have strong two-fold in-plane anisotropy. These findings are consistent with a Fermi-surface reconstruction caused by a unidirectional spin-density wave or stripe order.