We investigate how the intensity of Ramadan affects educational outcomes by exploiting spatio-temporal variation in annual fasting hours. Longer fasting hours are related to increases in student performance in a panel of TIMMS test scores (1995-2019) across Muslim countries but not other countries. Results are confirmed in a panel of PISA test scores (2003-2018) allowing within country-wave comparisons of Muslim to non-Muslim students across Europe. We provide evidence consistent with the hypothesis that a demanding Ramadan during adolescence affects educational performance by facilitating formation of social capital and social identity via increased religious participation and shared experiences among students.