In several unconventional superconductors, the highest superconducting transition temperature Tc is found in a region of the phase diagram where the antiferromagnetic transition temperature extrapolates to zero, signaling a putative quantum critical point. The elucidation of the interplay between these two phenomena - high-Tc superconductivity and magnetic quantum criticality - remains an important piece of the complex puzzle of unconventional superconductivity. In this paper, we combine sign-problem-free quantum Monte Carlo simulations and field-theoretical analytical calculations to unveil the microscopic mechanism responsible for the superconducting instability of a general low-energy model, called the spin-fermion model. In this approach, low-energy electronic states interact with each other via the exchange of quantum critical magnetic fluctuations. We find that even in the regime of moderately strong interactions, both the superconducting transition temperature and the pairing susceptibility are governed not by the properties of the entire Fermi surface, but instead by the properties of small portions of the Fermi surface called hot spots. Moreover, Tc increases with increasing interaction strength, until it starts to saturate at the crossover from hot-spots-dominated to Fermi-surface-dominated pairing. Our work provides not only invaluable insights into the system parameters that most strongly affect Tc, but also important benchmarks to assess the origin of superconductivity in both microscopic models and actual materials.