The present study aimed to evaluate the association between the consumption of energy-dense foods at 2 years of age and the consumption of foods and diet quality at 4 years of age. The sample included 705 children evaluated at 2 and 4 years of age, as part of the population-based birth cohort Generation XXI (Porto, Portugal). Data on sociodemographic and lifestyle factors of both children and mothers were collected by face-to-face interviews. The weight and height of children were measured by trained professionals. Based on FFQ, four energy-dense food groups were defined: soft drinks; sweets; cakes; salty snacks. A healthy eating index was developed using the WHO dietary recommendations for children (2006) aged 4 years. The associations were evaluated through Poisson regression models. After adjustment for maternal age and education, child's carer, child's siblings and child's BMI, higher consumption of energy-dense foods at 2 years of age was found to be associated with higher consumption of the same foods 2 years later. An inverse association was found between the intake ( ≥ median) of soft drinks (incidence rate ratio (IRR) = 0·74, 95 % CI 0·58, 0·95), salty snacks (IRR = 0·80, 95 % CI 0·65, 1·00) and sweets (IRR = 0·73, 95 % CI 0·58, 0·91) at 2 years of age and the consumption of fruit and vegetables at 4 years of age ( ≥ 5 times/d). Weekly and daily consumption of energy-dense foods at 2 years of age was associated with a lower healthy eating score at 4 years of age (IRR = 0·75, 95 % CI 0·58, 0·96; IRR = 0·56, 95 % CI 0·41, 0·77, respectively). The consumption of energy-dense foods at young ages is negatively associated with the diet quality of children a few years later.