We use social security records to document the heterogeneity in life expectancy by lifetime earnings for West Germany and we analyze how this longevity gap has evolved over cohorts. In line with previous studies, we provide evidence that the earnings-related longevity gap is increasing over cohorts. We then propose a decomposition to disentangle the role of the increasing earnings inequality over cohorts and the effect of changes in the earnings gradient on life expectancy. Finally, we study the distributional implications of the increasing longevity gap for the pension system. First, we show how the heterogeneity in life expectancy affects the distribution and the inequality of social security wealth and we document how this has evolved between the cohorts. Second, we calculate contribution/benefit ratios and compare the rates by lifetime earnings and between cohorts. Third, we extend the analysis by also accounting for survivor pensions and heterogeneous life expectancies of surviving spouses.