The retail food environment is a key modifiable driver of food choice and the risk of non-communicable diseases (NCDs). This study aimed to assess the relationship between the density of food retailers, body mass index (BMI), dietary patterns, and socioeconomic position in Mexico. Cross-sectional dietary data, BMI and socioeconomic characteristics of adult participants came from the nationally representative 2012 National Health and Nutrition Survey in Mexico. Geographical and food outlet data were obtained from official statistics. Densities of food outlets per census tract area (CTA) were calculated. Dietary patterns were determined using exploratory factor analysis and principal component analysis. The association of food environment variables, socioeconomic position, BMI, and dietary patterns was assessed using two-level multilevel linear regression models. Three dietary patterns were identified-the healthy, the unhealthy and the carbohydrates-and-drinks dietary pattern. Lower availability of fruit and vegetable stores was associated with an unhealthier dietary pattern whilst a higher restaurant density was associated with a carbohydrates-and-drinks pattern. A graded and inverse association was observed for fruit and vegetable store density and socioeconomic position (SEP)-lower-income populations had a reduced availability of fruit and vegetable stores, compared with higher-income populations. A higher density of convenience stores was associated with a higher BMI when adjusting for unhealthy dietary patterns. Upper-income households were more likely to consume healthy dietary patterns and middle-upper-income households were less likely to consume unhealthy dietary patterns when exposed to high densities of fruit and vegetable stores. When exposed to a high concentration of convenience stores, lower and upper-lower-income households were more likely to consume unhealthy dietary patterns. Food environment and sociodemographic conditions within neighbourhoods may affect dietary behaviours. Food environment interventions and policies which improve access to healthy foods and restrict access to unhealthy foods may facilitate healthier diets and contribute to the prevention of NCDs.