We estimated the affordability of food and beverages by energy density and nutrient quality in Mexico and tested for differential trends in affordability over time and by income quintile. We used the National Income and Expenditures Survey from 1994 to 2016, and information on the caloric and nutrient content of food and beverages from Mexican food composition tables. We estimated food energy density (kcal/kg) and nutrient quality of food and beverages using the nutrient-rich food index (NRFI). Affordability of food and beverages was defined as household monthly income needed to purchase 1000 kcal. The affordability index was expressed by quintiles of energy density and quintiles of the NRFI and by income quintile over time. We found that more energy-dense foods and food and beverages with lower nutrient quality were more affordable compared to healthier food and beverages. Food categories with lower energy density and a higher NRFI became less affordable over time for most income groups, but the burden was higher for lower-income households. A comprehensive national strategy should be implemented to make healthier options more affordable and discretional foods and beverages with lower nutrient quality less affordable.