Scattering of carriers with ionized impurities governs charge transport in doped semiconductors. However, electron interactions with ionized impurities cannot be fully described with quantitative first-principles calculations, so their understanding relies primarily on simplified models. Here we show an ab initio approach to compute the interactions between electrons and ionized impurities or other charged defects. It includes the short- and long-range electron-defect (e-d) interactions on equal footing, and allows for efficient interpolation of the e-d matrix elements. We combine the e-d and electron-phonon interactions in the Boltzmann transport equation to compute the carrier mobilities in doped silicon over a wide range of temperature and doping concentrations, spanning seamlessly the defect- and phonon-limited transport regimes. The individual contributions of the defect- and phonon-scattering mechanisms to the carrier relaxation times and mean-free paths are analyzed. Our method provides a powerful tool to study electronic interactions in doped materials. It broadens the scope of first-principles transport calculations, enabling studies of a wide range of doped semiconductors and oxides with application to electronics, energy and quantum technologies.