Urbanization contributes to changing food environments in sub-Saharan Africa, yet the implications for people's diets and nutrition remain insufficiently understood. Using four waves of nationally representative panel data from Malawi (2010–2019), we examine how local urbanization is associated with household dietary quality and nutrient adequacy. We find that urbanization modestly improves macronutrient adequacy and increases the consumption of animal-sourced foods. However, unhealthy food consumption also rises and we find a shift from whole towards refined grains. No consistent improvement in overall dietary quality is observed. Critically, effects differ by type of urbanization: the emergence of new agglomerations in otherwise rural areas, which we refer to as "rurbanization", is associated with significant declines in the consumption of various micronutrients, likely because the local food market infrastructure remains underdeveloped. Such deterioration is not observed in places where existing cities expand ("urban sprawl"). Mechanism analysis identifies household expenditure as the dominant pathway for positive diet effects, while simultaneous negative effects occur through the erosion of production-based pathways, such as subsistence cropping and livestock husbandry. These findings suggest that urbanization improves caloric and macronutrient adequacy, primarily through gains in purchasing power, whereas broader nutritional improvements are undermined through market developments that are insufficient to replace traditional own production systems. Policies should prioritize fresh food market infrastructure in emerging urban areas while protecting production-based nutritional pathways during the urban transition.