Background Childhood poverty is associated with elevated later risks for self-directed and externalised violence, but how risks are modified by parental socioeconomic mobility remains unclear. We investigated parental income trajectories during childhood and subsequent risks of self-harm and violent criminality in young adulthood.Methods Using Danish national registers, we delineated a nested case-control study of Danish citizens born from Jan 1, 1982, to Dec 31, 2000, with first hospital-treated self-harm episodes and first violent crime convictions at ages 15-33 years. Each case was matched on age and gender to 25 randomly selected controls. Parental income was assessed in birth-year and at ages 5 years, 10 years, and 15 years. We considered parental age, the child's number of siblings, parental mental health, and parental education to be covariates. We estimated incidence rate ratios (IRRs) by conditional logistic regression inherently adjusted for age, gender, and calendar year; we then made additional adjustments for the covariates considered.Findings We identified 21 267 first episodes of hospital-treated self-harm, to which we matched 531 675 controls, and 23 724 first violent crime convictions, to which we matched 593 100 controls. We observed inverse relationships between parental income and risks for the two outcomes for each of the ages parental income was measured. The longer a child lived in poorer circumstances, the higher their subsequent risks for self-harm and violent criminality, and vice versa for time spent living in affluent conditions. Associations were stronger for violent criminality than for self-harm. Compared with individuals who were born and remained in the most affluent families, all other income trajectories were associated with elevated risks for both outcomes. Those who remained in the least affluent quintile showed the highest risks for self-harm (IRR 7·2, 95% CI 6·6-7·9; 1174 [6%] cases) and for violent criminality (IRR 13·0; 95% CI 11·9-14·1; 1640 [7%] cases). The risk patterns were attenuated, but essentially persisted, after covariate adjustment. For any parental income level at birth, being upwardly mobile was associated with lower risk compared with downward mobility.Interpretation Parental income represents a multitude of unmeasured familial sociodemographic indices. Tackling the causes of inequality and associated psychosocial and sociocultural challenges to enable upwards socioeconomic mobility could potentially reduce risks for self-directed and externalised violence.