Improved versions of the segmented all-electron relativistically contracted (SARC) basis sets for the lanthanides are presented. The second-generation SARC2 basis sets maintain efficient construction of their predecessors and their individual adaptation to the DKH2 and ZORA Hamiltonians, but feature exponents optimized with a completely new orbital shape fitting procedure and a slightly expanded f space that results in sizable improvement in CASSCF energies and in significantly more accurate prediction of spin-orbit coupling parameters. Additionally, an extended set of polarization/correlation functions is constructed that is appropriate for multireference correlated calculations and new auxiliary basis sets for use in resolution-of-identity (density-fitting) approximations in combination with both DFT and wave function based treatments. Thus, the SARC2 basis sets extend the applicability of the first-generation DFT-oriented basis sets to routine all-electron wave function-based treatments of lanthanide complexes. The new basis sets are benchmarked with respect to excitation energies, radial distribution functions, optimized geometries, orbital eigenvalues, ionization potentials, and spin-orbit coupling parameters of lanthanide systems and are shown to be suitable for the description of magnetic and spectroscopic properties using both DFT and multireference wave function-based methods.