The JYFLTRAP double Penning trap at the Ion Guide Isotope Separator On-Line (IGISOL) facility has been used to measure the atomic masses of 13 neutron-rich rare-earth isotopes. Eight of the nuclides, 161 Pm, 163 Sm, 164,165 Eu, 167 Gd, and 165,167,168 Tb, were measured for the first time. The systematics of the mass surface has been studied via one-and two-neutron separation energies as well as neutron pairing-gap and shell-gap energies. The proton-neutron pairing strength has also been investigated. The impact of the new mass values on the astrophysical rapid neutron capture process has been studied. The calculated abundance distribution results in a better agreement with the solar abundance pattern near the top of the rare-earth abundance peak at around A ≈ 165.