This research aims to analyse the association between socioeconomic status (SES) and self-rated health (SRH) through its relationship with lifestyle factors, as well as examining these effects stratified by gender and age groups. A cross-sectional study was performed with a representative sample from Andalusia (Southern Spain) composed of 1200 adults. The study analysed several variables related to lifestyle (healthy diet, physical activity and tobacco and alcohol consumption) and SES (education and income), along with SRH. The joint effects of SRH and the set of variables were studied by using a hierarchical linear regression analysis. Later a path analysis was carried out to test the impact of gender and age group on these associations. The results show that a better SRH was reported by men with lower age, higher SES, more frequent physical activity, healthy diet, and lower alcohol use compared with their counterparts. Income was directly related to better SRH through more physical activity, a healthier diet and less alcohol consumption. SES had a greater positive relationship with women’s health than with men’s health. In addition, a greater explained variance in SRH was observed in older women based on SES and lifestyle factors. Our findings provide some cross-sectional evidence of the social inequalities in health mediated through lifestyle factors, with gender and age differences. Therefore, socioeconomic inequalities should be addressed by public and social policies considering the gender and age gaps.